Can't run rspec correctly - ruby-on-rails

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

Related

Unidirectional Relation failing with Factory Girl `can't write unknown attribute`

I have a model Event
class Event < ActiveRecord::Base
belongs_to :approved_by, class_name: 'User', foreign_key: 'approved_by'
end
And a model User which does not care about the reverse relation
class User < ActiveRecord::Base
include Authenticatable
end
With a Event factory like so:
FactoryGirl.define do
factory :event do
title "MyString"
description "...snip..."
start_time "2017-06-26 15:31:55"
end_time "2017-06-26 15:31:55"
venue "MyPlace"
status :active
approved_by { build :user }
trait :pending do
status :pending
approved_by nil
end
trait :active do
#no-op
end
end
end
When I try to assert that they factory works as intended, like so...
RSpec.describe Event, type: :model do
describe 'sanity checks' do
it { expect(build :event).to be_valid }
it { expect(create :event).to be_persisted }
end
end
I get the following errors:
```
drew$ rspec -b spec/models/event_spec.rb
FF
Failures:
1) Event sanity checks
Failure/Error: it { expect(build :event).to be_valid }
ActiveModel::MissingAttributeError:
can't write unknown attribute `approved_by`
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute.rb:138:in `with_value_from_database'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_set.rb:39:in `write_from_user'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_methods/write.rb:74:in `write_attribute_with_type_cast'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_methods/write.rb:56:in `write_attribute'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_methods/dirty.rb:96:in `write_attribute'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_methods.rb:373:in `[]='
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/associations/belongs_to_association.rb:83:in `replace_keys'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/associations/belongs_to_association.rb:14:in `replace'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/associations/singular_association.rb:17:in `writer'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/associations/builder/association.rb:123:in `approved_by='
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `public_send'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/strategy/build.rb:9:in `result'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activesupport-4.2.5/lib/active_support/notifications.rb:166:in `instrument'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/models/event_spec.rb:5:in `block (3 levels) in <top (required)>'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:254:in `instance_exec'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:254:in `block in run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `block in with_around_and_singleton_context_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `block in with_around_example_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `block in run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:604:in `block in run_around_example_hooks_for'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-rails-3.5.2/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:375:in `execute_with'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:607:in `run_around_example_hooks_for'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `with_around_example_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `with_around_and_singleton_context_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:251:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:627:in `block in run_examples'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `map'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `run_examples'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:589:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `block in run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `map'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (3 levels) in run_specs'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `map'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (2 levels) in run_specs'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1835:in `with_suite_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:112:in `block in run_specs'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:77:in `report'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:111:in `run_specs'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:87:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
# /Users/drew/.rvm/gems/ruby-2.2.6/bin/rspec:23:in `load'
# /Users/drew/.rvm/gems/ruby-2.2.6/bin/rspec:23:in `<main>'
# /Users/drew/.rvm/gems/ruby-2.2.6/bin/ruby_executable_hooks:15:in `eval'
# /Users/drew/.rvm/gems/ruby-2.2.6/bin/ruby_executable_hooks:15:in `<main>'
2) Event sanity checks
Failure/Error: it { expect(create :event).to be_persisted }
ActiveModel::MissingAttributeError:
can't write unknown attribute `approved_by`
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute.rb:138:in `with_value_from_database'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_set.rb:39:in `write_from_user'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_methods/write.rb:74:in `write_attribute_with_type_cast'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_methods/write.rb:56:in `write_attribute'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_methods/dirty.rb:96:in `write_attribute'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/attribute_methods.rb:373:in `[]='
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/associations/belongs_to_association.rb:83:in `replace_keys'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/associations/belongs_to_association.rb:14:in `replace'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/associations/singular_association.rb:17:in `writer'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activerecord-4.2.5/lib/active_record/associations/builder/association.rb:123:in `approved_by='
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `public_send'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/activesupport-4.2.5/lib/active_support/notifications.rb:166:in `instrument'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/factory_girl-4.8.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/models/event_spec.rb:6:in `block (3 levels) in <top (required)>'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:254:in `instance_exec'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:254:in `block in run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `block in with_around_and_singleton_context_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `block in with_around_example_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `block in run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:604:in `block in run_around_example_hooks_for'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-rails-3.5.2/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:375:in `execute_with'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:607:in `run_around_example_hooks_for'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `with_around_example_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `with_around_and_singleton_context_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:251:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:627:in `block in run_examples'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `map'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `run_examples'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:589:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `block in run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `map'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (3 levels) in run_specs'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `map'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (2 levels) in run_specs'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1835:in `with_suite_hooks'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:112:in `block in run_specs'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:77:in `report'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:111:in `run_specs'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:87:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/drew/.rvm/gems/ruby-2.2.6/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
# /Users/drew/.rvm/gems/ruby-2.2.6/bin/rspec:23:in `load'
# /Users/drew/.rvm/gems/ruby-2.2.6/bin/rspec:23:in `<main>'
# /Users/drew/.rvm/gems/ruby-2.2.6/bin/ruby_executable_hooks:15:in `eval'
# /Users/drew/.rvm/gems/ruby-2.2.6/bin/ruby_executable_hooks:15:in `<main>'
Finished in 0.75142 seconds (files took 2.6 seconds to load)
2 examples, 2 failures
Failed examples:
rspec ./spec/models/event_spec.rb:5 # Event sanity checks
rspec ./spec/models/event_spec.rb:6 # Event sanity checks
```
However when I try this via console it works fine...
[4] pry(main)> e = FactoryGirl.build(:event)
=> #<Event:0x007fe5ef1643d8
id: nil,
title: "MyString",
description:
"..snip..",
start_time: Mon, 26 Jun 2017 15:31:55 UTC +00:00,
end_time: Mon, 26 Jun 2017 15:31:55 UTC +00:00,
venue: "MyPlace",
main_image_cloudinary_id: nil,
status: 1,
approved_by: nil,
created_at: nil,
updated_at: nil>
[5] pry(main)> e.approved_by
=> #<User:0x007fe5ef157340
id: nil,
name: "Luther Johnston",
email: "guadalupe#brakus.com",
password_hash: "...snip...",
authentication_token: "...snip...",
activation_token: nil,
activation_date: Tue, 27 Jun 2017 00:00:00 UTC +00:00,
reset_password_token: nil,
created_at: nil,
updated_at: nil>
Since I rubber ducked myself about 2 seconds after hitting the post button, I'll go ahead and answer it.
My test database and development database were out of sync.
Running rake db:test:prepare solved the issue.

Why are my view specs behaving inconsistently?

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.

undefined method `unbind' for Proc (but I don't have unbind method)

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.

undefined method `deliveries' for ActionMailer::Base:Class

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.

Postgresql prepared statement in Rails : PG::Error: ERROR: bind message supplies 1 parameters, but prepared statement "a4" requires 0

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.

Resources