diff --git a/Rakefile b/Rakefile index fcf2e420..0b307700 100644 --- a/Rakefile +++ b/Rakefile @@ -24,13 +24,11 @@ task :default do if Tests::CurrentBundle.instance.appraisal_in_use? sh 'rake spec:unit --trace' sh 'rake spec:acceptance --trace' + elsif ENV['CI'] + exec 'appraisal install && appraisal rake --trace' else - if ENV['CI'] - exec 'appraisal install && appraisal rake --trace' - else - appraisal = Tests::CurrentBundle.instance.latest_appraisal - exec "appraisal install && appraisal #{appraisal} rake --trace" - end + appraisal = Tests::CurrentBundle.instance.latest_appraisal + exec "appraisal install && appraisal #{appraisal} rake --trace" end end diff --git a/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb b/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb index 2c81db7b..4e9bea61 100644 --- a/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +++ b/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb @@ -90,14 +90,12 @@ module Shoulda if attr_mass_assignable? if whitelisting? @failure_message_when_negated = "#{@attribute} was made accessible" + elsif protected_attributes.empty? + @failure_message_when_negated = 'no attributes were protected' else - if protected_attributes.empty? - @failure_message_when_negated = 'no attributes were protected' - else - @failure_message_when_negated = "#{class_name} is protecting " << - "#{protected_attributes.to_a.to_sentence}, " << - "but not #{@attribute}." - end + @failure_message_when_negated = "#{class_name} is protecting " << + "#{protected_attributes.to_a.to_sentence}, " << + "but not #{@attribute}." end true else diff --git a/lib/shoulda/matchers/active_record/serialize_matcher.rb b/lib/shoulda/matchers/active_record/serialize_matcher.rb index ca8965b0..f4415819 100644 --- a/lib/shoulda/matchers/active_record/serialize_matcher.rb +++ b/lib/shoulda/matchers/active_record/serialize_matcher.rb @@ -141,13 +141,11 @@ module Shoulda klass = serialization_coder if klass == @options[:type] true + elsif klass.respond_to?(:object_class) && klass.object_class == @options[:type] + true else - if klass.respond_to?(:object_class) && klass.object_class == @options[:type] - true - else - @missing = ":#{@name} should be a type of #{@options[:type]}" - false - end + @missing = ":#{@name} should be a type of #{@options[:type]}" + false end else true diff --git a/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb b/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb index 54508327..514cb83e 100644 --- a/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +++ b/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb @@ -952,22 +952,20 @@ module Shoulda end prefix << ', and saving it as the existing record, then' + elsif attribute_setter_for_existing_record + prefix << "Given an existing #{model.name}," + prefix << ' after setting ' + prefix << description_for_attribute_setter( + attribute_setter_for_existing_record + ) + prefix << ', then' else - if attribute_setter_for_existing_record - prefix << "Given an existing #{model.name}," - prefix << ' after setting ' - prefix << description_for_attribute_setter( - attribute_setter_for_existing_record - ) - prefix << ', then' - else - prefix << "Given an existing #{model.name} whose :#{attribute}" - prefix << ' is ' - prefix << Shoulda::Matchers::Util.inspect_value( - existing_value_read - ) - prefix << ', after' - end + prefix << "Given an existing #{model.name} whose :#{attribute}" + prefix << ' is ' + prefix << Shoulda::Matchers::Util.inspect_value( + existing_value_read + ) + prefix << ', after' end prefix << " making a new #{model.name} and setting "