Closed stephannv closed 9 months ago
I could reproduce the error on my local machine.
I noticed if you remove the .is_greater_than(0)
qualifier the tests pass so my guess is something related to that specific feature.
so this wont pass:
# spec/models/product_spec.rb
RSpec.describe Product, type: :model do
describe "validations" do
context "when is a test product" do
subject { Product.new(test: true) }
it { is_expected.not_to validate_numericality_of(:value).is_greater_than(0) }
end
context "when is not a test product" do
subject { Product.new(test: false) }
it { is_expected.to validate_numericality_of(:value).is_greater_than(0) }
end
end
end
but this will:
# spec/models/product_spec.rb
RSpec.describe Product, type: :model do
describe "validations" do
context "when is a test product" do
subject { Product.new(test: true) }
it { is_expected.not_to validate_numericality_of(:value) }
end
context "when is not a test product" do
subject { Product.new(test: false) }
it { is_expected.to validate_numericality_of(:value).is_greater_than(0) }
end
end
end
I could found the commit that created the problem.
Its the commit 95c39285d9b0235d21a7e6ca6ee99f0166f1c06b
.
Its a pretty big commit so I need take some time to study it, but if any of you guys more familiar with that PR could take a look a it maybe you could find out whats wrong faster.
EDIT: I forgot to mention the PR(1552)
Hi, thanks for reporting this problem. I’m travelling but can take a look at this next week.
Description
After upgrading to 6.0.0 some tests using negated numericality matcher are failing. To be more specific: I'm using the
greater_than
qualifier, I didn't try the others numericality matcher qualifiers.Reproduction Steps
rails g model product test:boolean value:integer
and run migrationsrails db:migrate
.Implement tests:
bundle exec rspec
. Result:Failures:
1) Product validations when is a test product is expected not to validate that :value looks like a number greater than 0 Failure/Error: it { is_expected.not_to validate_numericality_of(:value).is_greater_than(0) }