Fix RSpecRails/NegationBeValid

Another cop that only supports not_to instead of to_not.
This commit is contained in:
David Cook
2024-04-04 09:41:05 +11:00
parent 4db5aa593f
commit 6cff5c81fe
4 changed files with 14 additions and 24 deletions

View File

@@ -598,16 +598,6 @@ RSpecRails/InferredSpecType:
- 'spec/requests/voucher_adjustments_spec.rb'
- 'spec/routing/stripe_spec.rb'
# Offense count: 14
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: not_to, be_invalid
RSpecRails/NegationBeValid:
Exclude:
- 'spec/models/enterprise_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/variant_spec.rb'
# Offense count: 11
# Configuration parameters: Include.
# Include: app/models/**/*.rb

View File

@@ -260,18 +260,18 @@ describe Enterprise do
it "commas at the beginning and end are disallowed" do
enterprise = build(:enterprise, preferred_shopfront_taxon_order: ",1,2,3")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
enterprise = build(:enterprise, preferred_shopfront_taxon_order: "1,2,3,")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
end
it "any other characters are invalid" do
enterprise = build(:enterprise, preferred_shopfront_taxon_order: "a1,2,3")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
enterprise = build(:enterprise, preferred_shopfront_taxon_order: ".1,2,3")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
enterprise = build(:enterprise, preferred_shopfront_taxon_order: " 1,2,3")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
end
end
@@ -295,18 +295,18 @@ describe Enterprise do
it "commas at the beginning and end are disallowed" do
enterprise = build(:enterprise, preferred_shopfront_producer_order: ",1,2,3")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
enterprise = build(:enterprise, preferred_shopfront_producer_order: "1,2,3,")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
end
it "any other characters are invalid" do
enterprise = build(:enterprise, preferred_shopfront_producer_order: "a1,2,3")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
enterprise = build(:enterprise, preferred_shopfront_producer_order: ".1,2,3")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
enterprise = build(:enterprise, preferred_shopfront_producer_order: " 1,2,3")
expect(enterprise).to be_invalid
expect(enterprise).not_to be_valid
end
end
@@ -336,7 +336,7 @@ describe Enterprise do
it "does not validate if URL is invalid and can't be infered" do
e = build(:enterprise, white_label_logo_link: 'with spaces')
expect(e).to be_invalid
expect(e).not_to be_valid
end
end
end

View File

@@ -276,7 +276,7 @@ module Spree
product.variant_unit_name = nil
product.variant_unit_scale = nil
expect(product).to be_invalid
expect(product).not_to be_valid
end
it "requires a unit scale when variant unit is weight" do

View File

@@ -11,7 +11,7 @@ describe Spree::Variant do
context "validations" do
it "should validate price is greater than 0" do
variant.price = -1
expect(variant).to be_invalid
expect(variant).not_to be_valid
end
it "should validate price is 0" do
@@ -21,7 +21,7 @@ describe Spree::Variant do
it "should validate unit_value is greater than 0" do
variant.unit_value = 0
expect(variant).to be_invalid
expect(variant).not_to be_valid
end
describe "tax category" do