You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# foo.rb## == Schema Information## Table name: foo## id :integer not null, primary key# some_bool_val :boolean not nullclassFoo < ApplicationRecordvalidates:some_bool_val,inclusion: {in: [true,false],allow_nil: false,allow_blank: false},uniqueness: {if: :some_bool_val}end
and a spec
# foo_spec.rbRSpec.describeFoo,type: :modeldo# this test passescontext'with some_bool_val true'dosubject{create(:foo,some_bool_val: true)}it{shouldvalidate_uniqueness_of:some_bool_val}end# this test produces the errorcontext'with some_bool_value false'dosubject{create(:foo,some_bool_val: false)}it{should_notvalidate_uniqueness_of:some_bool_val}endend
full trace:
Failures:
1) Foo with some_bool_value false should not validate that :some_bool_value is case-sensitively unique
Failure/Error: it { should_not validate_uniqueness_of :some_bool_value }
NoMethodError:
undefined method `attribute_setter' for nil:NilClass
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/shoulda-matchers-3.1.2/lib/shoulda/matchers/active_model/allow_value_matcher.rb:405:in `failure_message'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/shoulda-matchers-3.1.2/lib/shoulda/matchers/active_model/disallow_value_matcher.rb:69:in `failure_message_when_negated'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/shoulda-matchers-3.1.2/lib/shoulda/matchers/active_model/validation_matcher.rb:133:in `failure_reason_when_negated'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/shoulda-matchers-3.1.2/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb:346:in `failure_reason_when_negated'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/shoulda-matchers-3.1.2/lib/shoulda/matchers/active_model/validation_matcher.rb:68:in `block in failure_message_when_negated'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/shoulda-matchers-3.1.2/lib/shoulda/matchers/active_model/validation_matcher.rb:67:in `tap'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/shoulda-matchers-3.1.2/lib/shoulda/matchers/active_model/validation_matcher.rb:67:in `failure_message_when_negated'
# ./spec/models/foo_spec.rb:67:in `block (3 levels) in <top (required)>'
# ./spec/support/database_cleaner.rb:12:in `block (3 levels) in <top (required)>'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/database_cleaner-1.6.2/lib/database_cleaner/generic/base.rb:16:in `cleaning'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/database_cleaner-1.6.2/lib/database_cleaner/base.rb:98:in `cleaning'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/database_cleaner-1.6.2/lib/database_cleaner/configuration.rb:86:in `block (2 levels) in cleaning'
# $HOME/.rvm/gems/ruby-2.5.0@my-project/gems/database_cleaner-1.6.2/lib/database_cleaner/configuration.rb:87:in `cleaning'
# ./spec/support/database_cleaner.rb:11:in `block (2 levels) in <top (required)>'
Finished in 3.62 seconds (files took 3.53 seconds to load)
165 examples, 1 failure, 1 pending
Failed examples:
rspec ./spec/models/foo_spec.rb:67 # Foo with some_bool_value false should not validate that :some_bool_value is case-sensitively unique
Randomized with seed 53832
The text was updated successfully, but these errors were encountered:
@aaronmallen Thanks for reminding me about this. A lot of people have reported this -- #904 contains a bunch of references -- so if you don't mind I'm going to close this in favor of that. I have a branch going that fixes this bug and provides more information in case of a failure, so I'll have that done soon.
Getting the following error when trying to conditionally validate a boolean value:
Given an environment with:
given a class with a boolean column
and a spec
full trace:
The text was updated successfully, but these errors were encountered: