I'm getting some strange results from view specs
Failure/Error: assert_select "div.fileinput-new.thumbnail"
ArgumentError:
wrong number of arguments (3 for 1)
Ok, so this seems self explanatory (though I'm not sure what are the 3 arguments referenced).
However, if I run the suite again, I might get 0 errors. And the next, 5 errors, of the same type as above but referencing different DOM elements.
There is nothing fancy in any of these specs
describe do
build :object / create :object
#object = assign(:object, object )
it 'displays the DOM elements' do
render
asset_select #DOM_elements
end
end
What could cause this kind of inconsistent coverage of view specs?
An example stack trace
Failure/Error: assert_select "div.fileinput-new.thumbnail"
ArgumentError:
wrong number of arguments (3 for 1)
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/actionview-4.2.6/lib/action_view/helpers/text_helper.rb:52:in `concat'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:165:in `evaluate'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:165:in `block in xpath'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:156:in `map'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:156:in `xpath'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:193:in `css_internal'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:76:in `block in css'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:187:in `block in each'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `upto'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `each'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:75:in `inject'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:75:in `css'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb:20:in `select'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:174:in `assert_select'
# ./spec/views/users/settings/profile.html.erb_spec.rb:24:in `block (4 levels) in <top (required)>'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:295:in `nest_selection'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:177:in `block in assert_select'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:174:in `tap'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:174:in `assert_select'
# ./spec/views/users/settings/profile.html.erb_spec.rb:22:in `block (3 levels) in <top (required)>'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:236:in `instance_exec'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:236:in `block in run'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:478:in `block in with_around_and_singleton_context_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:435:in `block in with_around_example_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:478:in `block in run'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:618:in `block in run_around_example_hooks_for'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-rails-3.4.2/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:425:in `instance_exec'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:425:in `instance_exec'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:389:in `execute_with'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:620:in `block (2 levels) in run_around_example_hooks_for'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:621:in `run_around_example_hooks_for'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:478:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:435:in `with_around_example_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:478:in `with_around_and_singleton_context_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:233:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:581:in `block in run_examples'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:577:in `map'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:577:in `run_examples'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:543:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:544:in `block in run'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:544:in `map'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:544:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:119:in `block (3 levels) in run_specs'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:119:in `map'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:119:in `block (2 levels) in run_specs'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1680:in `with_suite_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:118:in `block in run_specs'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/reporter.rb:77:in `report'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:117:in `run_specs'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:93:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:78:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/gems/rspec-core-3.4.4/exe/rspec:4:in `<top (required)>'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/bin/rspec:23:in `load'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/bin/rspec:23:in `<main>'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/bin/ruby_executable_hooks:15:in `eval'
# /Users/me/.rvm/gems/ruby-2.2.3#myapp/bin/ruby_executable_hooks:15:in `<main>'
This is not a definitive answer: it appears that, for some weird reason, the evaluate method in the Nokogiri's Searchable module considers the concat() function as a custom XPath function instead of the internal XPath function.
External XPath functions are called as normal ruby methods in the context of the handler attribute of evaluate. Normally the handler is the SubstitutionContext class but in your case it seems that sometimes this gets the context of the TextHelper module where the concat method is defined, accepting just 1 parameter (whereas the XPath's concat() function accepts any number of parameters). I think that this can lead to the errors you observe.
Could you open the searchable.rb file (see the stack trace for its location) on this line and add before it some debug messages to inspect the contents of the following variables?
puts "ctx #{ctx.inspect}"
puts "path #{path.inspect}"
puts "handler #{handler.inspect}"
if handler.respond_to?(:concat)
puts "concat #{handler.method(:concat).inspect}"
else
puts "not responding to :concat"
end
Then, can you provide the output printed for one of the failing tests?
Update: the output showed that indeed the tests context was being polluted by the ActionView::TextHelpers module and in the end it turned out that there was a ActionView::Helpers module included in a model used in the tests.
Related
rspec version: 3.5
rails version: 5.2
Controller:
def show
# Remove all source.
end
Test controller:
describe 'GET #show' do
it 'returns not found' do
get :show, params: {id: post}
expect(response).to have_http_status(:not_found)
end
end
This test case will test a 404 status, but got 500 internal server error:
expected the response to have status code :not_found (404) but it was :internal_server_error (500)
When ran the test with --backtrace:
$ rspec spec/controller/posts_controller_spec.rb --backtrace
Can found this line got error:
Failure/Error: expect(response).to have_http_status(:not_found)
expected the response to have status code :not_found (404) but it was :internal_server_error (500)
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-support-3.7.1/lib/rspec/support.rb:97:in `block in <module:Support>'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-support-3.7.1/lib/rspec/support.rb:106:in `notify_failure'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.7.0/lib/rspec/expectations/fail_with.rb:35:in `fail_with'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.7.0/lib/rspec/expectations/handler.rb:40:in `handle_failure'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.7.0/lib/rspec/expectations/handler.rb:50:in `block in handle_matcher'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.7.0/lib/rspec/expectations/handler.rb:27:in `with_matcher'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.7.0/lib/rspec/expectations/handler.rb:48:in `handle_matcher'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/given_core-3.8.0/lib/given/rspec/monkey.rb:21:in `handle_matcher'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.7.0/lib/rspec/expectations/expectation_target.rb:65:in `to'
# ./spec/controllers/posts_controller_spec.rb:8:in `block (4 levels) in <top (required)>'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:254:in `instance_exec'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:254:in `block in run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:500:in `block in with_around_and_singleton_context_hooks'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:457:in `block in with_around_example_hooks'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:466:in `block in run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:606:in `block in run_around_example_hooks_for'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:342:in `call'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-rails-3.7.2/lib/rspec/rails/example/controller_example_group.rb:191:in `block (2 levels) in <module:ControllerExampleGroup>'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:447:in `instance_exec'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:447:in `instance_exec'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:375:in `execute_with'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:608:in `block (2 levels) in run_around_example_hooks_for'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:342:in `call'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-rails-3.7.2/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:447:in `instance_exec'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:447:in `instance_exec'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:375:in `execute_with'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:608:in `block (2 levels) in run_around_example_hooks_for'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:342:in `call'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:609:in `run_around_example_hooks_for'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:466:in `run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:457:in `with_around_example_hooks'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:500:in `with_around_and_singleton_context_hooks'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:251:in `run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:628:in `block in run_examples'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:624:in `map'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:624:in `run_examples'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:590:in `run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:591:in `block in run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:591:in `map'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:591:in `run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:591:in `block in run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:591:in `map'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:591:in `run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:118:in `block (3 levels) in run_specs'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:118:in `map'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:118:in `block (2 levels) in run_specs'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/configuration.rb:1926:in `with_suite_hooks'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:113:in `block in run_specs'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/reporter.rb:79:in `report'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:112:in `run_specs'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:87:in `run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:71:in `run'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/exe/rspec:4:in `<top (required)>'
# /Users/user/.rbenv/versions/2.3.3/bin/rspec:23:in `load'
# /Users/user/.rbenv/versions/2.3.3/bin/rspec:23:in `<main>'
So is it the version conflict between rspec-rails and rails?
In your code
def show
# Remove all source.
end
There is no render or redirect code in this method, So it will try to render the implicit view show.html.erb. But if you don't have that view defined, it will return 500(internal server error)
If you just want to show not found, then give
def show
head :not_found
end
Have a basic helper test:
require 'rails_helper'
describe BuilderHelper do
...
describe 'press events classes' do
let(:account) { create(:candidate_profile).account }
before { allow_any_instance_of(Object).to receive(:current_account).and_return account }
specify do
expect_any_instance_of(PublicPage).to receive(:show_press?).and_return true
expect_any_instance_of(PublicPage).to receive(:show_events?).and_return true
expect(press_events_classes(account)).to eq 'section'
end
...
end
...
end
And it gives strange error:
Failure/Error: before { allow_any_instance_of(Object).to receive(:current_account).and_return account }
NoMethodError:
undefined method `unbind' for #<Proc:0x00000009803640>
# ./spec/helpers/builder_helper_spec.rb:27:in `block (3 levels) in <top (required)>'
# ./spec/support/vcr.rb:16:in `block (2 levels) in <top (required)>'
(that's it, that's the whole error log)
So the error is in before block.
The problem is that I don't have an "unbind" method anywhere.
I looked in Rails repo - it doesn't seem to have anything too.
Don't know what's the problem. Can anyone help where to look?
Update
Alright, thanks to comment I got this:
1) BuilderHelper press events classes
Failure/Error: before { allow_any_instance_of(Object).to receive(:current_account).and_return account }
NoMethodError:
undefined method `unbind' for #<Proc:0x000000025ff9e0>
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/proxy.rb:372:in `original_unbound_method_handle_from_ancestor_for'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/proxy.rb:355:in `original_method_handle_for'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/method_double.rb:28:in `original_method'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/method_double.rb:57:in `define_proxy_method'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/method_double.rb:50:in `configure_method'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/method_double.rb:150:in `add_stub'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/proxy.rb:112:in `add_stub'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/any_instance/proxy.rb:38:in `block in stub'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/any_instance/proxy.rb:81:in `map'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/any_instance/proxy.rb:81:in `perform_proxying'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/any_instance/proxy.rb:37:in `stub'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/matchers/receive.rb:88:in `setup_method_substitute'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/matchers/receive.rb:81:in `setup_any_instance_method_substitute'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/matchers/receive.rb:49:in `setup_any_instance_allowance'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/targets.rb:45:in `define_matcher'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-mocks-3.0.4/lib/rspec/mocks/targets.rb:14:in `block in delegate_to'
# ./spec/helpers/builder_helper_spec.rb:27:in `block (3 levels) in <top (required)>'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:349:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:410:in `block in run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:410:in `each'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:410:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:485:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:340:in `run_before_example'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:147:in `block in run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `call'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-rails-3.0.2/lib/rspec/rails/adapters.rb:72:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:430:in `block (2 levels) in run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `call'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# ./spec/support/vcr.rb:16:in `block (2 levels) in <top (required)>'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:430:in `block (2 levels) in run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `call'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:432:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:485:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:303:in `with_around_example_hooks'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:145:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:494:in `block in run_examples'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:490:in `map'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:490:in `run_examples'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:457:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:458:in `block in run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:458:in `map'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:458:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:112:in `block (2 levels) in run_specs'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:112:in `map'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:112:in `block in run_specs'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:54:in `report'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:108:in `run_specs'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:86:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
# /home/dell/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>'
# /home/dell/.rvm/gems/ruby-2.1.5/bin/rspec:23:in `load'
# /home/dell/.rvm/gems/ruby-2.1.5/bin/rspec:23:in `<main>'
# /home/dell/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
# /home/dell/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
Still not sure what to do.
Update
Solved by replacing this:
before { allow_any_instance_of(Object).to receive(:current_account).and_return account }
With this:
before { allow_any_instance_of(BuilderHelper).to receive(:current_account).and_return account }
So my best guess which is hard to tell base on this but what I had happen was I in fact stubbed out the find and returned a proc object in its place.
let(:record) { create :record } # This is a Proc
allow(Object).to receive(:find).and_return(record)
allow_any_instance_of(Object).to receive(:update) # This calls unbind
Sadly trying to figure out where the first stub happened. But I bet it is there in your code.
I started randomly getting the following stack trace in my project on this repo when running tests. My buddy forked and cloned and he doesn't get the error. I also have other projects that call the deliveries method and they have no problems. I have tried deleting the file and re cloning and it still doesn't work. I honestly have no idea where to start. Any help would be greatly appreciated.
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `deliveries' for ActionMailer::Base:Class
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/actionmailer-4.1.1/lib/action_mailer/base.rb:553:in `method_missing'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/actionmailer-4.1.1/lib/action_mailer/test_case.rb:59:in `initialize_test_deliveries'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-rails-3.0.1/lib/rspec/rails/adapters.rb:109:in `block (2 levels) in setup'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:294:in `instance_exec'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:294:in `instance_exec'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:349:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:410:in `block in run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:410:in `each'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:410:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:485:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:340:in `run_before_example'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:147:in `block in run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `call'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-rails-3.0.1/lib/rspec/rails/adapters.rb:68:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:294:in `instance_exec'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:294:in `instance_exec'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:430:in `block (2 levels) in run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `call'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:432:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:485:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:303:in `with_around_example_hooks'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:145:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:494:in `block in run_examples'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:490:in `map'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:490:in `run_examples'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:457:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:458:in `block in run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:458:in `map'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:458:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:112:in `block (2 levels) in run_specs'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:112:in `map'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:112:in `block in run_specs'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/reporter.rb:54:in `report'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:108:in `run_specs'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:86:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:70:in `run'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:38:in `invoke'
# /Users/Evan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.2/exe/rspec:4:in `<top (required)>'
# /Users/Evan/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `load'
# /Users/Evan/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `<main>'
# /Users/Evan/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
# /Users/Evan/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
#
# Showing full backtrace because every line was filtered out.
# See docs for RSpec::Configuration#backtrace_exclusion_patterns and
# RSpec::Configuration#backtrace_inclusion_patterns for more information.
Apparently the problem was my gemset. I am not sure how it happened because it was seemingly in the middle of writing code in a test but I installed a new gemset and all is good. Thanks for anyone who took the time to read this and or edit my post.
I have introduced a new field to a model file in my 4.0.0 Ruby on Rails application and added a validation to make sure it is unique using the following line:
validates_uniqueness_of :source_id
Immediately after that my RSpec/Capybara test suite started breaking with the following error message:
Failure/Error: let(:product) { FactoryGirl.create(:product) }
ActiveRecord::StatementInvalid:
PG::Error: ERROR: bind message supplies 1 parameters, but prepared statement "a4" requires 0
SELECT 1 AS one FROM "products" WHERE "products"."source_id" = 'Product GUID6' LIMIT 1
I understand this has to do with Postgresql prepared statements, but am not sure as to what needs to be done exactly to resolve this issue.
As an additional piece of information, I have updated the DB table with index for field "source_id" with unique: true option.
Your input is greatly appreciated.
I am using FactoryGirl gem to handle the creation of my model object such as:
let(:product) { FactoryGirl.create(:product) }
subject { product_dimension }
describe "method" do
it { should respond_to(:product) }
end
and here is the snippet from the actual Factories.rb file:
factory :product do
sequence(:source_id) { |n| "Product GUID#{n}" }
sequence(:title) { |n| "Prodcut #{n}" }
content "Lorem ipsum"
channel_id 1
end
Here is the exception stack trace:
1) ProductDimension method dimension
Failure/Error: let(:product) { FactoryGirl.create(:product) }
ActiveRecord::StatementInvalid:
PG::Error: ERROR: bind message supplies 1 parameters, but prepared statement "a4" requires 0
: SELECT 1 AS one FROM "products" WHERE "products"."source_id" = 'Product GUID6' LIMIT 1
# ./spec/models/product_dimension_spec.rb:4:in `block (2 levels) in <top (required)>'
# ./spec/models/product_dimension_spec.rb:7:in `block (2 levels) in <top (required)>'
# ./spec/models/product_dimension_spec.rb:9:in `block (2 levels) in <top (required)>'
# ./spec/models/product_dimension_spec.rb:28:in `block (3 levels) in <top (required)>'
Here is a more detailed stack trace:
1) ProductDimension methods dimension
Failure/Error: let(:product) { FactoryGirl.create(:product) }
ActiveRecord::StatementInvalid:
PG::Error: ERROR: bind message supplies 1 parameters, but prepared statement "a4" requires 0
: SELECT 1 AS one FROM "products" WHERE "products"."source_id" = 'GUID 6' LIMIT 1
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:780:in `get_last_result'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:780:in `exec_cache'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:139:in `block in exec_query'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:425:in `block in log'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:420:in `log'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:885:in `select'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:24:in `select_all'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:30:in `select_one'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:36:in `select_value'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/relation/finder_methods.rb:174:in `exists?'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/validations/uniqueness.rb:28:in `validate_each'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validator.rb:153:in `block in validate'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validator.rb:150:in `each'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validator.rb:150:in `validate'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:283:in `_callback_before_17'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:467:in `_run__2082443422329982594__validate__callbacks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validations.rb:373:in `run_validations!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validations/callbacks.rb:106:in `block in run_validations!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__2082443422329982594__validation__callbacks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validations/callbacks.rb:106:in `run_validations!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validations.rb:314:in `valid?'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/validations.rb:70:in `valid?'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/validations.rb:77:in `perform_validations'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/validations.rb:57:in `save!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/attribute_methods/dirty.rb:41:in `save!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `block in save!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `save!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/configuration.rb:14:in `block in initialize'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `[]'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `create'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:12:in `block in result'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `tap'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/notifications.rb:161:in `instrument'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:22:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/strategy_syntax_method_registrar.rb:19:in `block in define_singular_strategy_method'
# ./spec/models/event_dimension_spec.rb:5:in `block (2 levels) in <top (required)>'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block (2 levels) in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `fetch'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block in let'
# ./spec/models/event_dimension_spec.rb:8:in `block (2 levels) in <top (required)>'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block (2 levels) in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `fetch'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block in let'
# ./spec/models/event_dimension_spec.rb:10:in `block (2 levels) in <top (required)>'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block (2 levels) in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `fetch'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:433:in `block (2 levels) in its'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block (2 levels) in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `fetch'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:440:in `should'
# ./spec/models/event_dimension_spec.rb:32:in `block (3 levels) in <top (required)>'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:114:in `instance_eval'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:114:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:179:in `call'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:179:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/hooks.rb:87:in `block (2 levels) in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/hooks.rb:89:in `call'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/hooks.rb:89:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/hooks.rb:427:in `run_hook'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:339:in `run_around_each_hooks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:111:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:400:in `block in run_examples'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:396:in `map'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:396:in `run_examples'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:381:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `map'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `map'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:28:in `map'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:28:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/reporter.rb:58:in `report'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:25:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/runner.rb:80:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/runner.rb:17:in `block in autorun'
This is a bug in ActiveRecord. It will be fixed in Rails 4.0.3.
I have figured it out. Thanks to #muistooshort for pointing me in the right direction with the last comment. There was an issue with the relationship between my models. It prompted me to revise the need for my ProductDimension model at which point I completely discarded it in favour of another approach.
I came across this error while Upgrading Rails from 5.1.3 to 5.2 and I was able to fix it by updating cancancan gem to the latest version i.e 3.0.2.
I am in the process of upgrading our test suite to Capybara 2.1, and am running into the strangest issue when running the test suite.
Using:
ruby 1.9.3p392
rails 3.2.12
rspec 2.13.0
capybara 2.1.0
When I run my tests for an entire suite (failing at once with descriptive formatting):
rspec spec/acceptance/non-webdriver-dependent/ --fail-fast -f d
The following error is thrown:
Failure/Error: within(".sidebar") do
ArgumentError:
wrong number of arguments (3 for 1)
When running with the --backtrace option, the following is reported:
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.12/lib/action_view/helpers/text_helper.rb:51:in `concat'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:159:in `evaluate'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:159:in `block in xpath'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1..9/lib/nokogiri/xml/node.rb:150:in `map'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:150:in `xpath'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:214:in `css'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/rack_test/browser.rb:85:in `find'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/rack_test/driver.rb:70:in `find_css'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/node/finders.rb:152:in `block in resolve_query'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/node/base.rb:77:in `synchronize'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/node/finders.rb:150:in `resolve_query'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/node/finders.rb:35:in `block in find'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/node/base.rb:81:in `synchronize'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/node/finders.rb:30:in `find'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/session.rb:354:in `block (2 levels) in <class:Session>'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/session.rb:221:in `within'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/capybara-2.1.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
# ./spec/acceptance/non-webdriver-dependent/bronze/company_job_postings_index_sidebar_spec.rb:15:in `block (3 levels) in <top (required)>'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:114:in `instance_eval'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:114:in `block in run'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:254:in `with_around_each_hooks'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:111:in `run'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:386:in `map'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:386:in `run_examples'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:371:in `run'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:372:in `block in run'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:372:in `map'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:372:in `run'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `map'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block in run'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/reporter.rb:34:in `report'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:25:in `run'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
# /Users/steve/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
However, when I run one test at a time, I have no problem whatsover. This is mind-boggling to me, and any insight anyone may have into this would be highly appreciated! It is important to know this only occurs on the acceptance tests using the default driver rather than the selenium tests. Additionally, this error occurred only AFTER upgrading to capybara 2.1.0.
I got the same error. Like some people saying, the problem is include ActionView::Helpers::TextHelper. In my case, I included it in a model. Fortunately I could remove it from the model and this error is cleared.