From 5532f4359aa332b10de7d46f876eaffd4a95b5b6 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Mon, 4 Jan 2016 22:45:48 -0700 Subject: [PATCH] Enable ignoring_interference_by_writer by default Forcing people to add ignoring_interference_by_writer for each and every case in which an attribute changes incoming values is pretty obnoxious on our part (for instance, when using the numericality matcher against an integer column + `only_integer`). So now, it's enabled by default. This effectively means that people should never get AtttributeChangedValueErrors again. --- NEWS.md | 14 +- .../ignore_interference_by_writer.rb | 6 +- .../validate_presence_of_matcher.rb | 3 +- .../ignoring_interference_by_writer.rb | 61 ++----- .../active_model/allow_value_matcher_spec.rb | 165 ++++++++++-------- .../validate_absence_of_matcher_spec.rb | 12 -- .../validate_acceptance_of_matcher_spec.rb | 3 - .../validate_confirmation_of_matcher_spec.rb | 3 - .../validate_exclusion_of_matcher_spec.rb | 6 - .../validate_inclusion_of_matcher_spec.rb | 12 -- .../validate_length_of_matcher_spec.rb | 9 - .../validate_numericality_of_matcher_spec.rb | 33 ---- .../validate_presence_of_matcher_spec.rb | 12 -- .../validate_uniqueness_of_matcher_spec.rb | 8 - 14 files changed, 122 insertions(+), 225 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3a00a61ee..ed0ade22a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,11 +12,10 @@ (formerly CouldNotSetAttributeError) when used against an attribute that is an enum in an ActiveRecord model. -### Features - * Add a `ignoring_interference_by_writer` qualifier to all matchers, not just - `allow_value`. This makes it possible to get around CouldNotSetAttributeErrors - (now AttributeChangedValueErrors) that you are probably well acquainted with. + `allow_value`. *This is enabled by default, which means that you should never + get a CouldNotSetAttributeError again.* (You may get some more information if + a test fails, however.) ### Improvements @@ -25,9 +24,6 @@ (You'll see a huge difference in the output of the numericality and uniqueness matchers in particular.) -* The CouldNotSetAttributeError that you have probably seen is now called - AttributeChangedValueError. - * Matchers now raise an error if any attributes that the matcher is attempting to set do not exist on the model. @@ -36,6 +32,10 @@ now contain information as to what value the matcher set on the attribute when it failed, this change guarantees that the correct value will be shown. +* Continue to detect if attributes change incoming values, but now instead of + immediately seeing a CouldNotSetAttributeError, you will only be informed + about it if the test you've written fails. + # 3.0.1 ### Bug fixes diff --git a/lib/shoulda/matchers/active_model/qualifiers/ignore_interference_by_writer.rb b/lib/shoulda/matchers/active_model/qualifiers/ignore_interference_by_writer.rb index 04f1ab689..719d96b63 100644 --- a/lib/shoulda/matchers/active_model/qualifiers/ignore_interference_by_writer.rb +++ b/lib/shoulda/matchers/active_model/qualifiers/ignore_interference_by_writer.rb @@ -6,7 +6,7 @@ module Qualifiers class IgnoreInterferenceByWriter attr_reader :setting, :condition - def initialize(argument = :never) + def initialize(argument = :always) set(argument) @changed = false end @@ -59,6 +59,10 @@ def considering?(value) end end + def always? + setting == :always + end + def never? setting == :never end diff --git a/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb index c217212aa..c2060ca65 100644 --- a/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +++ b/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb @@ -147,14 +147,13 @@ class ValidatePresenceOfMatcher < ValidationMatcher def initialize(attribute) super @expected_message = :blank - @ignore_interference_by_writer = - Qualifiers::IgnoreInterferenceByWriter.new(when: :blank?) end def matches?(subject) super(subject) if secure_password_being_validated? + ignore_interference_by_writer.default_to(when: :blank?) disallows_and_double_checks_value_of!(blank_value, @expected_message) else disallows_original_or_typecast_value?(blank_value, @expected_message) diff --git a/spec/support/unit/shared_examples/ignoring_interference_by_writer.rb b/spec/support/unit/shared_examples/ignoring_interference_by_writer.rb index 2edb20e06..2fc45360d 100644 --- a/spec/support/unit/shared_examples/ignoring_interference_by_writer.rb +++ b/spec/support/unit/shared_examples/ignoring_interference_by_writer.rb @@ -1,6 +1,5 @@ shared_examples_for 'ignoring_interference_by_writer' do |common_config| valid_tests = [ - :raise_if_not_qualified, :accept_if_qualified_but_changing_value_does_not_interfere, :reject_if_qualified_but_changing_value_interferes ] @@ -10,61 +9,39 @@ define_method(:common_config) { common_config } context 'when the writer method for the attribute changes incoming values' do - context 'and the matcher has not been qualified with ignoring_interference_by_writer' do - config_for_test = tests[:raise_if_not_qualified] + context 'and the value change does not cause a test failure' do + config_for_test = tests[:accept_if_qualified_but_changing_value_does_not_interfere] if config_for_test - it 'raises an AttributeChangedValueError' do + it 'accepts (and does not raise an error)' do args = build_args(config_for_test) scenario = build_scenario_for_validation_matcher(args) matcher = matcher_from(scenario) - assertion = lambda do - expect(scenario.record).to matcher - end - - expect(&assertion).to raise_error( - Shoulda::Matchers::ActiveModel::AllowValueMatcher::AttributeChangedValueError - ) + expect(scenario.record).to matcher end end end - context 'and the matcher has been qualified with ignoring_interference_by_writer' do - context 'and the value change does not cause a test failure' do - config_for_test = tests[:accept_if_qualified_but_changing_value_does_not_interfere] + context 'and the value change causes a test failure' do + config_for_test = tests[:reject_if_qualified_but_changing_value_interferes] - if config_for_test - it 'accepts (and does not raise an error)' do - args = build_args(config_for_test) - scenario = build_scenario_for_validation_matcher(args) - matcher = matcher_from(scenario) + if config_for_test + it 'lists how the value got changed in the failure message' do + args = build_args(config_for_test) + scenario = build_scenario_for_validation_matcher(args) + matcher = matcher_from(scenario) - expect(scenario.record).to matcher.ignoring_interference_by_writer + assertion = lambda do + expect(scenario.record).to matcher end - end - end - - context 'and the value change causes a test failure' do - config_for_test = tests[:reject_if_qualified_but_changing_value_interferes] - - if config_for_test - it 'lists how the value got changed in the failure message' do - args = build_args(config_for_test) - scenario = build_scenario_for_validation_matcher(args) - matcher = matcher_from(scenario) - - assertion = lambda do - expect(scenario.record).to matcher.ignoring_interference_by_writer - end - if config_for_test.key?(:expected_message_includes) - message = config_for_test[:expected_message_includes] - expect(&assertion).to fail_with_message_including(message) - else - message = config_for_test.fetch(:expected_message) - expect(&assertion).to fail_with_message(message) - end + if config_for_test.key?(:expected_message_includes) + message = config_for_test[:expected_message_includes] + expect(&assertion).to fail_with_message_including(message) + else + message = config_for_test.fetch(:expected_message) + expect(&assertion).to fail_with_message(message) end end end diff --git a/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb index 3c252e266..211f5a5af 100644 --- a/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb @@ -410,29 +410,55 @@ end context 'when the attribute interferes with attempts to be set' do - context 'when the matcher has not been qualified with #ignoring_interference_by_writer' do - context 'when the attribute cannot be changed from nil to non-nil' do - it 'raises an AttributeChangedValueError' do - model = define_active_model_class 'Example' do - attr_reader :name + context 'when the attribute cannot be changed from nil to non-nil' do + context 'and the record remains valid' do + it 'accepts (and does not raise an AttributeChangedValueError)' do + model = define_active_model_class 'Example', accessors: [:name] do + def name=(_value) + nil + end + end + + expect(model.new).to allow_value('anything').for(:name) + end + end + + context 'and the record becomes invalid' do + it 'rejects with an appropriate failure message' do + model = define_active_model_class 'Example', accessors: [:name] do + validates_presence_of :name def name=(_value) nil end end - assertion = -> { + assertion = lambda do expect(model.new).to allow_value('anything').for(:name) - } + end - expect(&assertion).to raise_error( - described_class::AttributeChangedValueError - ) + message = <<-MESSAGE.strip +After setting :name to ‹"anything"› -- which was read back as ‹nil› -- +the matcher expected the Example to be valid, but it was invalid +instead, producing these validation errors: + +* name: ["can't be blank"] + +As indicated in the message above, :name seems to be changing certain +values as they are set, and this could have something to do with why +this test is failing. If you've overridden the writer method for this +attribute, then you may need to change it to make this test pass, or do +something else entirely. + MESSAGE + + expect(&assertion).to fail_with_message(message) end end + end - context 'when the attribute cannot be changed from non-nil to nil' do - it 'raises an AttributeChangedValueError' do + context 'when the attribute cannot be changed from non-nil to nil' do + context 'and the record remains valid' do + it 'accepts (and does not raise an AttributeChangedValueError)' do model = define_active_model_class 'Example', accessors: [:name] do def name=(value) if value @@ -443,104 +469,93 @@ def name=(value) record = model.new(name: 'some name') - assertion = -> { - expect(record).to allow_value(nil).for(:name) - } - - expect(&assertion).to raise_error( - described_class::AttributeChangedValueError - ) + expect(record).to allow_value(nil).for(:name) end end - context 'when the attribute cannot be changed from a non-nil value to another non-nil value' do - it 'raises an AttributeChangedValueError' do - model = define_active_model_class 'Example' do - attr_reader :name + context 'and the record becomes invalid' do + it 'rejects with an appropriate failure message' do + model = define_active_model_class 'Example', accessors: [:name] do + validates_absence_of :name - def name=(_value) - @name = 'constant name' + def name=(value) + if value + super(value) + end end end record = model.new(name: 'some name') - assertion = -> { - expect(record).to allow_value('another name').for(:name) - } + assertion = lambda do + expect(record).to allow_value(nil).for(:name) + end - expect(&assertion).to raise_error( - described_class::AttributeChangedValueError - ) + message = <<-MESSAGE.strip +After setting :name to ‹nil› -- which was read back as ‹"some name"› -- +the matcher expected the Example to be valid, but it was invalid +instead, producing these validation errors: + +* name: ["must be blank"] + +As indicated in the message above, :name seems to be changing certain +values as they are set, and this could have something to do with why +this test is failing. If you've overridden the writer method for this +attribute, then you may need to change it to make this test pass, or do +something else entirely. + MESSAGE + + expect(&assertion).to fail_with_message(message) end end end - context 'when the matcher has been qualified with #ignoring_interference_by_writer' do - context 'when the attribute cannot be changed from nil to non-nil' do - it 'does not raise an error at all' do - model = define_active_model_class 'Example' do - attr_reader :name - + context 'when the attribute cannot be changed from a non-nil value to another non-nil value' do + context 'and the record remains valid' do + it 'accepts (and does not raise an AttributeChangedValueError)' do + model = define_active_model_class 'Example', accessors: [:name] do def name=(_value) - nil + super('constant name') end end - assertion = lambda do - expect(model.new). - to allow_value('anything'). - for(:name). - ignoring_interference_by_writer - end + record = model.new(name: 'some name') - expect(&assertion).not_to raise_error + expect(record).to allow_value('another name').for(:name) end end - context 'when the attribute cannot be changed from non-nil to nil' do - it 'does not raise an error at all' do - model = define_active_model_class 'Example' do - attr_reader :name + context 'and the record becomes invalid' do + it 'rejects with an appropriate failure message' do + model = define_active_model_class 'Example', accessors: [:name] do + validates_format_of :name, with: /another name/ def name=(value) - @name = value unless value.nil? + super('constant name') end end record = model.new(name: 'some name') assertion = lambda do - expect(record). - to allow_value(nil). - for(:name). - ignoring_interference_by_writer + expect(record).to allow_value('another name').for(:name) end - expect(&assertion).not_to raise_error - end - end + message = <<-MESSAGE.strip +After setting :name to ‹"another name"› -- which was read back as +‹"constant name"› -- the matcher expected the Example to be valid, but +it was invalid instead, producing these validation errors: - context 'when the attribute cannot be changed from a non-nil value to another non-nil value' do - it 'does not raise an error at all' do - model = define_active_model_class 'Example' do - attr_reader :name +* name: ["is invalid"] - def name=(_value) - @name = 'constant name' - end - end - - record = model.new(name: 'some name') - - assertion = lambda do - expect(record). - to allow_value('another name'). - for(:name). - ignoring_interference_by_writer - end +As indicated in the message above, :name seems to be changing certain +values as they are set, and this could have something to do with why +this test is failing. If you've overridden the writer method for this +attribute, then you may need to change it to make this test pass, or do +something else entirely. + MESSAGE - expect(&assertion).not_to raise_error + expect(&assertion).to fail_with_message(message) end end end diff --git a/spec/unit/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb index c277bc2cd..192f9463f 100644 --- a/spec/unit/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb @@ -36,9 +36,6 @@ def self.available_column_types it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :next_value }, @@ -86,9 +83,6 @@ def validation_matcher_scenario_args it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :upcase - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :upcase }, @@ -124,9 +118,6 @@ def validation_matcher_scenario_args it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :next_value }, @@ -154,9 +145,6 @@ def validation_matcher_scenario_args it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :next_value }, diff --git a/spec/unit/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb index 6fa150ca9..09fd900d0 100644 --- a/spec/unit/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb @@ -13,9 +13,6 @@ it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :never_falsy, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :never_falsy, }, diff --git a/spec/unit/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb index 7859bfa24..ed32cbfca 100644 --- a/spec/unit/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb @@ -31,9 +31,6 @@ it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :password, diff --git a/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb index a39e0b85f..9e789a4de 100644 --- a/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb @@ -20,9 +20,6 @@ it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :attr, @@ -151,9 +148,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :attr, diff --git a/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb index 835215d76..d944c466a 100644 --- a/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb @@ -269,9 +269,6 @@ def validation_matcher_scenario_args it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: -> (value) { value || valid_values.first } }, @@ -327,9 +324,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: -> (value) { value.presence || valid_values.first @@ -526,9 +520,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { attribute_name: :attr, changing_values_with: :next_value, @@ -649,9 +640,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { attribute_name: :attr, changing_values_with: :next_value, diff --git a/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb index 65430616d..eb6249477 100644 --- a/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb @@ -25,9 +25,6 @@ it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :upcase, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :upcase, }, @@ -92,9 +89,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :upcase, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :upcase, }, @@ -151,9 +145,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :upcase, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :upcase, }, diff --git a/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb index c7ba5beda..d6d346238 100644 --- a/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb @@ -130,9 +130,6 @@ def default_validation_values it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :next_value, }, @@ -219,9 +216,6 @@ def default_validation_values it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value_or_numeric_value, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :next_value_or_numeric_value, }, @@ -291,9 +285,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :next_value, }, @@ -354,9 +345,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_next_value, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :next_next_value, }, @@ -450,9 +438,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_next_value, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :next_next_value, }, @@ -548,9 +533,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :attr, @@ -650,9 +632,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :attr, @@ -748,9 +727,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :attr, @@ -850,9 +826,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :attr, @@ -956,9 +929,6 @@ def configure_validation_matcher(matcher) it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :attr, @@ -1616,9 +1586,6 @@ def set_attr!; self.attr = 5 end it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :next_value, - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :next_value, }, diff --git a/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb index 8c2fbdedb..9495bdf10 100644 --- a/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb @@ -13,9 +13,6 @@ it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :never_falsy - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :nil_to_blank }, @@ -70,9 +67,6 @@ it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :never_falsy - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :nil_to_blank }, @@ -125,9 +119,6 @@ def model_creator it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :never_falsy - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :nil_to_blank }, @@ -186,9 +177,6 @@ def build_record_having_and_belonging_to_many it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - changing_values_with: :never_falsy - }, accept_if_qualified_but_changing_value_does_not_interfere: { changing_values_with: :nil_to_blank }, diff --git a/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb index 767186994..ad1371582 100644 --- a/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb @@ -452,10 +452,6 @@ it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - attribute_name: :attr, - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :attr, @@ -757,10 +753,6 @@ it_supports( 'ignoring_interference_by_writer', tests: { - raise_if_not_qualified: { - attribute_name: :attr, - changing_values_with: :next_value, - }, reject_if_qualified_but_changing_value_interferes: { model_name: 'Example', attribute_name: :attr,