From 6cff5c81fe92e24d0b901387bdff1eabb4929d07 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 4 Apr 2024 09:41:05 +1100 Subject: [PATCH] Fix RSpecRails/NegationBeValid Another cop that only supports not_to instead of to_not. --- .rubocop_todo.yml | 10 ---------- spec/models/enterprise_spec.rb | 22 +++++++++++----------- spec/models/spree/product_spec.rb | 2 +- spec/models/spree/variant_spec.rb | 4 ++-- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3e274bdd4b..dfc1120676 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 8c79d69987..e764c9da73 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -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 diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index 49fc233147..d23ba61fbe 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -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 diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index 696b4822d7..aec627bf71 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -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