My environment
ruby 2.3.1
rails (4.2.7.1)
shoulda-matchers (3.1.1)
rspec-rails (~> 3.5)
My Class
Class A
enum name: ['a', 'b']
validates :name, uniqueness: true
end
My Spec
subject { build(:a, name: 'a') }
it { is_expected.to validate_uniqueness_of(:name) }
Failed Results
ArgumentError:
'A' is not a valid name
The problem here is that shoulda-matcher check for case_sensitive too.
Right, that's the default behavior of the uniqueness validation, that it is case-sensitive-aware.
You can tell the matcher not to test for this by adding .ignore_case_sensitivity to the end of the matcher.
Cheers!
@mcmire Thanks.
Right, that's the default behavior of the uniqueness validation, that it is case-sensitive-aware.
You can tell the matcher not to test for this by adding
.ignore_case_sensitivityto the end of the matcher.Cheers!
The qualifier is .ignoring_case_sensitivity :)
Most helpful comment
The qualifier is
.ignoring_case_sensitivity:)