1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

Rename failure_message and negative_failure_message

* fixes #108 : RSpec 2.10 compatibility
* remove unnecessary attr_readr
This commit is contained in:
Brian Shaver 2013-01-08 12:29:01 -05:00 committed by Jason Draper
parent db83bb2cef
commit 4f8684c6db
44 changed files with 118 additions and 120 deletions

View file

@ -6,7 +6,7 @@ PATH
bourne (~> 1.2.0)
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
actionmailer (3.2.9)
actionpack (= 3.2.9)

View file

@ -1,5 +1,5 @@
PATH
remote: /vagrant
remote: /Users/draper/Dropbox/Development/shoulda-matchers
specs:
shoulda-matchers (1.4.2)
activesupport (>= 3.0.0)

View file

@ -1,5 +1,5 @@
PATH
remote: /vagrant
remote: /Users/draper/Dropbox/Development/shoulda-matchers
specs:
shoulda-matchers (1.4.2)
activesupport (>= 3.0.0)

View file

@ -1,5 +1,5 @@
PATH
remote: /vagrant
remote: /Users/draper/Dropbox/Development/shoulda-matchers
specs:
shoulda-matchers (1.4.2)
activesupport (>= 3.0.0)

View file

@ -19,7 +19,7 @@ module Shoulda # :nodoc:
end
class AssignToMatcher # :nodoc:
attr_reader :failure_message, :negative_failure_message
attr_reader :failure_message_for_should, :failure_message_for_should_not
def initialize(variable)
@variable = variable.to_s
@ -64,12 +64,12 @@ module Shoulda # :nodoc:
def assigned_value?
if @controller.instance_variables.map(&:to_s).include?("@#{@variable}")
@negative_failure_message =
@failure_message_for_should_not =
"Didn't expect action to assign a value for @#{@variable}, " <<
"but it was assigned to #{assigned_value.inspect}"
true
else
@failure_message =
@failure_message_for_should =
"Expected action to assign a value for @#{@variable}"
false
end
@ -78,12 +78,12 @@ module Shoulda # :nodoc:
def kind_of_expected_class?
if @options.key?(:expected_class)
if assigned_value.kind_of?(@options[:expected_class])
@negative_failure_message =
@failure_message_for_should_not =
"Didn't expect action to assign a kind of #{@options[:expected_class]} " <<
"for #{@variable}, but got one anyway"
true
else
@failure_message =
@failure_message_for_should =
"Expected action to assign a kind of #{@options[:expected_class]} " <<
"for #{@variable}, but got #{assigned_value.inspect} " <<
"(#{assigned_value.class.name})"
@ -97,12 +97,12 @@ module Shoulda # :nodoc:
def equal_to_expected_value?
if @options[:check_value]
if @options[:expected_value] == assigned_value
@negative_failure_message =
@failure_message_for_should_not =
"Didn't expect action to assign #{@options[:expected_value].inspect} " <<
"for #{@variable}, but got it anyway"
true
else
@failure_message =
@failure_message_for_should =
"Expected action to assign #{@options[:expected_value].inspect} " <<
"for #{@variable}, but got #{assigned_value.inspect}"
false

View file

@ -19,11 +19,11 @@ module Shoulda # :nodoc:
filters_key?
end
def failure_message
def failure_message_for_should
"Expected #{@key} to be filtered; filtered keys: #{filtered_keys.join(', ')}"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{@key} to be filtered"
end

View file

@ -12,7 +12,7 @@ module Shoulda # :nodoc:
end
class RedirectToMatcher # :nodoc:
attr_reader :failure_message, :negative_failure_message
attr_reader :failure_message_for_should, :failure_message_for_should_not
def initialize(url_or_description, context, &block)
if block
@ -44,10 +44,10 @@ module Shoulda # :nodoc:
def redirects_to_url?
begin
@context.send(:assert_redirected_to, url)
@negative_failure_message = "Didn't expect to redirect to #{url}"
@failure_message_for_should_not = "Didn't expect to redirect to #{url}"
true
rescue Shoulda::Matchers::AssertionError => error
@failure_message = error.message
@failure_message_for_should = error.message
false
end
end

View file

@ -20,7 +20,7 @@ module Shoulda # :nodoc:
end
class RenderTemplateMatcher # :nodoc:
attr_reader :failure_message, :negative_failure_message
attr_reader :failure_message_for_should, :failure_message_for_should_not
def initialize(options, message, context)
@options = options
@ -48,10 +48,10 @@ module Shoulda # :nodoc:
def renders_template?
begin
@context.send(:assert_template, @options, @message)
@negative_failure_message = "Didn't expect to render #{@template}"
@failure_message_for_should_not = "Didn't expect to render #{@template}"
true
rescue Shoulda::Matchers::AssertionError => error
@failure_message = error.message
@failure_message_for_should = error.message
false
end
end

View file

@ -33,11 +33,11 @@ module Shoulda # :nodoc:
rendered_with_layout? && rendered_with_expected_layout?
end
def failure_message
def failure_message_for_should
"Expected #{expectation}, but #{result}"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}, but #{result}"
end

View file

@ -35,11 +35,11 @@ module Shoulda # :nodoc:
content_type_matches_regexp? || content_type_matches_string?
end
def failure_message
def failure_message_for_should
"Expected #{expectation}"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}"
end

View file

@ -30,11 +30,11 @@ module Shoulda # :nodoc:
correct_status_code? || correct_status_code_range?
end
def failure_message
def failure_message_for_should
"Expected #{expectation}"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}"
end

View file

@ -33,7 +33,7 @@ module Shoulda # :nodoc:
@context = context
end
attr_reader :failure_message, :negative_failure_message
attr_reader :failure_message_for_should, :failure_message_for_should_not
def to(params)
@params = stringify_params(params)
@ -80,13 +80,13 @@ module Shoulda # :nodoc:
{ :method => @method, :path => @path },
@params)
@negative_failure_message = "Didn't expect to #{description}"
@failure_message_for_should_not = "Didn't expect to #{description}"
true
rescue ::ActionController::RoutingError => error
@failure_message = error.message
@failure_message_for_should = error.message
false
rescue Shoulda::Matchers::AssertionError => error
@failure_message = error.message
@failure_message_for_should = error.message
false
end
end

View file

@ -32,11 +32,11 @@ module Shoulda # :nodoc:
assigned_correct_value? || cleared_value?
end
def failure_message
def failure_message_for_should
"Expected #{expectation}, but #{result}"
end
def negative_failure_message
def failure_message_for_should_not
"Didn't expect #{expectation}, but #{result}"
end

View file

@ -22,8 +22,6 @@ module Shoulda # :nodoc:
@options = {}
end
attr_reader :failure_message, :negative_failure_message
def to(value)
if !value.is_a?(String) && !value.is_a?(Regexp)
raise "cannot match against #{value.inspect}"
@ -53,11 +51,11 @@ module Shoulda # :nodoc:
description
end
def failure_message
def failure_message_for_should
"Expected #{expectation}"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}"
end

View file

@ -106,11 +106,11 @@ module Shoulda # :nodoc:
end
end
def failure_message
def failure_message_for_should
"Expected #{expectation}"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}"
end

View file

@ -16,7 +16,7 @@ module Shoulda # :nodoc:
end
class AllowMassAssignmentOfMatcher # :nodoc:
attr_reader :failure_message, :negative_failure_message
attr_reader :failure_message_for_should, :failure_message_for_should_not
def initialize(attribute)
@attribute = attribute.to_s
@ -35,12 +35,12 @@ module Shoulda # :nodoc:
@subject = subject
if attr_mass_assignable?
if whitelisting?
@negative_failure_message = "#{@attribute} was made accessible"
@failure_message_for_should_not = "#{@attribute} was made accessible"
else
if protected_attributes.empty?
@negative_failure_message = 'no attributes were protected'
@failure_message_for_should_not = 'no attributes were protected'
else
@negative_failure_message = "#{class_name} is protecting " <<
@failure_message_for_should_not = "#{class_name} is protecting " <<
"#{protected_attributes.to_a.to_sentence}, " <<
"but not #{@attribute}."
end
@ -48,9 +48,9 @@ module Shoulda # :nodoc:
true
else
if whitelisting?
@failure_message = "Expected #{@attribute} to be accessible"
@failure_message_for_should = "Expected #{@attribute} to be accessible"
else
@failure_message = "Did not expect #{@attribute} to be protected"
@failure_message_for_should = "Did not expect #{@attribute} to be protected"
end
false
end

View file

@ -60,11 +60,11 @@ module Shoulda # :nodoc:
end
end
def failure_message
def failure_message_for_should
"Did not expect #{expectation}, got error: #{@matched_error}"
end
def negative_failure_message
def failure_message_for_should_not
"Expected #{expectation}, got #{error_description}"
end

View file

@ -20,8 +20,8 @@ module Shoulda # :nodoc:
self
end
def failure_message
@allow_matcher.negative_failure_message
def failure_message_for_should
@allow_matcher.failure_message_for_should_not
end
def allowed_types

View file

@ -88,7 +88,7 @@ module Shoulda # :nodoc:
if allows_all_values_in_array? && allows_blank_value? && allows_nil_value? && disallows_value_outside_of_array?
true
else
@failure_message = "#{@array} doesn't match array in validation"
@failure_message_for_should = "#{@array} doesn't match array in validation"
false
end
end

View file

@ -24,8 +24,8 @@ module Shoulda # :nodoc:
'integer'
end
def failure_message
@disallow_value_matcher.failure_message
def failure_message_for_should
@disallow_value_matcher.failure_message_for_should
end
end
end

View file

@ -48,7 +48,7 @@ module Shoulda # :nodoc:
"only allow #{allowed_types} values for #{@attribute}"
end
def failure_message
def failure_message_for_should
submatcher_failure_messages.last
end
@ -71,7 +71,7 @@ module Shoulda # :nodoc:
end
def submatcher_failure_messages
failing_submatchers.map(&:failure_message)
failing_submatchers.map(&:failure_message_for_should)
end
def failing_submatchers

View file

@ -96,7 +96,7 @@ module Shoulda # :nodoc:
@subject.send(setter, existing.send(scope))
true
else
@failure_message = "#{class_name} doesn't seem to have a #{scope} attribute."
@failure_message_for_should = "#{class_name} doesn't seem to have a #{scope} attribute."
false
end
end
@ -133,11 +133,11 @@ module Shoulda # :nodoc:
if allows_value_of(existing_value, @expected_message)
@subject.send("#{scope}=", previous_value)
@negative_failure_message <<
@failure_message_for_should_not <<
" (with different value of #{scope})"
true
else
@failure_message << " (with different value of #{scope})"
@failure_message_for_should << " (with different value of #{scope})"
false
end
end

View file

@ -2,7 +2,7 @@ module Shoulda # :nodoc:
module Matchers
module ActiveModel # :nodoc:
class ValidationMatcher # :nodoc:
attr_reader :failure_message
attr_reader :failure_message_for_should
def initialize(attribute)
@attribute = attribute
@ -14,8 +14,8 @@ module Shoulda # :nodoc:
self
end
def negative_failure_message
@negative_failure_message || @failure_message
def failure_message_for_should_not
@failure_message_for_should_not || @failure_message_for_should
end
def matches?(subject)
@ -29,10 +29,10 @@ module Shoulda # :nodoc:
allow = allow_value_matcher(value, message)
if allow.matches?(@subject)
@negative_failure_message = allow.failure_message
@failure_message_for_should_not = allow.failure_message_for_should
true
else
@failure_message = allow.negative_failure_message
@failure_message_for_should = allow.failure_message_for_should_not
false
end
end
@ -41,10 +41,10 @@ module Shoulda # :nodoc:
disallow = allow_value_matcher(value, message)
if disallow.matches?(@subject)
@failure_message = disallow.negative_failure_message
@failure_message_for_should = disallow.failure_message_for_should_not
false
else
@negative_failure_message = disallow.failure_message
@failure_message_for_should_not = disallow.failure_message_for_should
true
end
end

View file

@ -50,11 +50,11 @@ module Shoulda
update_only_correct?
end
def failure_message
def failure_message_for_should
"Expected #{expectation} (#{@problem})"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}"
end

View file

@ -124,11 +124,11 @@ module Shoulda # :nodoc:
validate_correct?
end
def failure_message
def failure_message_for_should
"Expected #{expectation} (#{@missing})"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}"
end

View file

@ -51,11 +51,11 @@ module Shoulda # :nodoc:
correct_primary?
end
def failure_message
def failure_message_for_should
"Expected #{expectation} (#{@missing})"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}"
end

View file

@ -37,11 +37,11 @@ module Shoulda # :nodoc:
index_exists? && correct_unique?
end
def failure_message
def failure_message_for_should
"Expected #{expectation} (#{@missing})"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}"
end

View file

@ -16,19 +16,19 @@ module Shoulda # :nodoc:
@attribute = attribute.to_s
end
attr_reader :failure_message, :negative_failure_message
attr_reader :failure_message_for_should, :failure_message_for_should_not
def matches?(subject)
@subject = subject
if readonly_attributes.include?(@attribute)
@negative_failure_message = "Did not expect #{@attribute} to be read-only"
@failure_message_for_should_not = "Did not expect #{@attribute} to be read-only"
true
else
if readonly_attributes.empty?
@failure_message = "#{class_name} attribute #{@attribute} " <<
@failure_message_for_should = "#{class_name} attribute #{@attribute} " <<
'is not read-only'
else
@failure_message = "#{class_name} is making " <<
@failure_message_for_should = "#{class_name} is making " <<
"#{readonly_attributes.to_a.to_sentence} " <<
"read-only, but not #{@attribute}."
end

View file

@ -67,7 +67,7 @@ module Shoulda # :nodoc:
end
end
def failure_message
def failure_message_for_should
if @options.key?(:expected_query_count)
"Expected ##{@options[:method_name]} to cause #{@options[:expected_query_count]} database queries but it actually caused #{@queries.length} queries:" + friendly_queries
else
@ -75,7 +75,7 @@ module Shoulda # :nodoc:
end
end
def negative_failure_message
def failure_message_for_should_not
if @options[:expected_query_count]
"Expected ##{@options[:method_name]} to not cause #{@options[:expected_query_count]} database queries but it actually caused #{@queries.length} queries:" + friendly_queries
else

View file

@ -36,11 +36,11 @@ module Shoulda # :nodoc:
serialization_valid? && type_valid?
end
def failure_message
def failure_message_for_should
"Expected #{expectation} (#{@missing})"
end
def negative_failure_message
def failure_message_for_should_not
"Did not expect #{expectation}"
end

View file

@ -70,7 +70,7 @@ module Shoulda # :nodoc:
self
end
def failure_message
def failure_message_for_should
base = "Expected #{delegating_method_name} to delegate to #{target_method_name}"
add_clarifications_to(base)
end

View file

@ -12,7 +12,7 @@ describe Shoulda::Matchers::ActionController::AssignToMatcher do
matcher = assign_to(:var).with_kind_of(Fixnum)
matcher.matches?(controller)
matcher.failure_message.should =~ /but got wrong class \(WrongClass\)$/
matcher.failure_message_for_should.should =~ /but got wrong class \(WrongClass\)$/
end
context 'a controller that assigns to an instance variable' do

View file

@ -13,7 +13,7 @@ describe Shoulda::Matchers::ActionController::FilterParamMatcher do
matcher.matches?(nil).should be_false
matcher.failure_message.should =~ /Expected other to be filtered.*secret/
matcher.failure_message_for_should.should =~ /Expected other to be filtered.*secret/
end
def filter(param)

View file

@ -120,7 +120,7 @@ describe Shoulda::Matchers::ActionMailer::HaveSentEmailMatcher do
should_not have_sent_email.multipart
matcher = have_sent_email.multipart(true)
matcher.matches?(Mailer.the_email(nil))
matcher.failure_message.should =~ /Expected sent email being multipart/
matcher.failure_message_for_should.should =~ /Expected sent email being multipart/
end
it 'matches the body with a regexp' do
@ -155,98 +155,98 @@ describe Shoulda::Matchers::ActionMailer::HaveSentEmailMatcher do
should have_sent_email.with_subject(/is spam$/)
matcher = have_sent_email.with_subject(/totally safe/)
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email with subject/
matcher.failure_message_for_should.should =~ /Expected sent email with subject/
end
it 'accepts sent e-mail based on a string sender' do
should have_sent_email.from('do-not-reply@example.com')
matcher = have_sent_email.from('you@example.com')
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email from/
matcher.failure_message_for_should.should =~ /Expected sent email from/
end
it 'accepts sent e-mail based on a regexp sender' do
should have_sent_email.from(/@example\.com/)
matcher = have_sent_email.from(/you@/)
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email from/
matcher.failure_message_for_should.should =~ /Expected sent email from/
end
it 'accepts sent e-mail based on the body' do
should have_sent_email.with_body(/is spam\./)
matcher = have_sent_email.with_body(/totally safe/)
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email with body/
matcher.failure_message_for_should.should =~ /Expected sent email with body/
end
it 'accepts sent e-mail based on a text/plain part' do
should have_sent_email.with_part('text/plain', /is spam\./)
matcher = have_sent_email.with_part('text/plain', /HTML is spam/)
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email with a text\/plain part containing/
matcher.failure_message_for_should.should =~ /Expected sent email with a text\/plain part containing/
end
it 'accepts sent e-mail based on a text/html part' do
should have_sent_email.with_part('text/html', /HTML is spam/)
matcher = have_sent_email.with_part('text/html', /HTML is not spam\./)
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email with a text\/html part containing/
matcher.failure_message_for_should.should =~ /Expected sent email with a text\/html part containing/
end
it 'accept sent e-mail based on the recipient' do
should have_sent_email.to('myself@me.com')
matcher = have_sent_email.to('you@example.com')
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email to/
matcher.failure_message_for_should.should =~ /Expected sent email to/
end
it 'accepts sent e-mail based on cc string' do
should have_sent_email.cc('joe@bob.com')
matcher = have_sent_email.cc('you@example.com')
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email cc/
matcher.failure_message_for_should.should =~ /Expected sent email cc/
end
it 'accepts sent-email based on cc regex' do
should have_sent_email.cc(/@bob\.com/)
matcher = have_sent_email.cc(/us@/)
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email cc/
matcher.failure_message_for_should.should =~ /Expected sent email cc/
end
it 'accepts sent e-mail based on cc list' do
should have_sent_email.with_cc(['you@you.com', 'joe@bob.com'])
matcher = have_sent_email.with_cc(['you@example.com'])
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email with cc/
matcher.failure_message_for_should.should =~ /Expected sent email with cc/
end
it 'accepts sent e-mail based on bcc string' do
should have_sent_email.bcc('goodbye@hello.com')
matcher = have_sent_email.bcc('test@hello.com')
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email bcc/
matcher.failure_message_for_should.should =~ /Expected sent email bcc/
end
it 'accepts sent e-mail based on bcc regex' do
should have_sent_email.bcc(/@example\.com/)
matcher = have_sent_email.bcc(/you@/)
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email bcc/
matcher.failure_message_for_should.should =~ /Expected sent email bcc/
end
it 'accepts sent e-mail based on bcc list' do
should have_sent_email.with_bcc(['sam@bob.com', 'test@example.com'])
matcher = have_sent_email.with_bcc(['you@you.com', 'joe@bob.com'])
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email with bcc/
matcher.failure_message_for_should.should =~ /Expected sent email with bcc/
end
it 'accepts sent-email when it is multipart' do
should have_sent_email.multipart
matcher = have_sent_email.multipart(false)
matcher.matches?(nil)
matcher.failure_message.should =~ /Expected sent email not being multipart/
matcher.failure_message_for_should.should =~ /Expected sent email not being multipart/
end
it 'lists all the deliveries within failure message' do
@ -254,7 +254,7 @@ describe Shoulda::Matchers::ActionMailer::HaveSentEmailMatcher do
matcher = have_sent_email.to('you@example.com')
matcher.matches?(nil)
matcher.failure_message.should =~ /Deliveries:\n"This is spam" to \["myself@me\.com"\]\n"This is spam" to \["myself@me\.com"\]/
matcher.failure_message_for_should.should =~ /Deliveries:\n"This is spam" to \["myself@me\.com"\]\n"This is spam" to \["myself@me\.com"\]/
end
it 'allows chaining' do

View file

@ -70,7 +70,7 @@ describe Shoulda::Matchers::ActiveModel::AllowMassAssignmentOfMatcher do
matcher.matches?(no_protected_attributes).should be_true
matcher.negative_failure_message.should_not be_nil
matcher.failure_message_for_should_not.should_not be_nil
end
end

View file

@ -116,7 +116,7 @@ describe Shoulda::Matchers::ActiveModel::AllowValueMatcher do
matcher.matches?(validating_format(:with => /abc/, :strict => true))
matcher.negative_failure_message.should == 'Expected exception to include /abc/ ' +
matcher.failure_message_for_should_not.should == 'Expected exception to include /abc/ ' +
'when attr is set to "xyz", got Attr is invalid'
end
end

View file

@ -22,13 +22,13 @@ describe Shoulda::Matchers::ActiveModel::DisallowValueMatcher do
end
it "delegates its failure message to its allow matcher's negative failure message" do
allow_matcher = stub_everything(:negative_failure_message => 'allow matcher failure')
allow_matcher = stub_everything(:failure_message_for_should_not => 'allow matcher failure')
Shoulda::Matchers::ActiveModel::AllowValueMatcher.stubs(:new).returns(allow_matcher)
matcher = matcher('abcde').for(:attr).with_message('good message')
matcher.matches?(validating_format(:with => /abc/, :message => 'good message'))
matcher.failure_message.should == 'allow matcher failure'
matcher.failure_message_for_should.should == 'allow matcher failure'
end
it 'matches if the message is correct but the value is not' do

View file

@ -38,7 +38,7 @@ describe Shoulda::Matchers::ActiveModel::OnlyIntegerMatcher do
matcher.matches?(define_model(:example, :attr => :string).new)
matcher.failure_message.should include 'Expected errors to include "must be an integer"'
matcher.failure_message_for_should.should include 'Expected errors to include "must be an integer"'
end
end

View file

@ -27,7 +27,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher do
the_matcher.matches?(define_model(:example, :attr => :string).new)
the_matcher.failure_message.should include 'Expected errors to include "must be an integer"'
the_matcher.failure_message_for_should.should include 'Expected errors to include "must be an integer"'
end
end
@ -45,7 +45,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher do
the_matcher.matches?(validating_numericality)
the_matcher.failure_message.should include 'Expected errors to include "must be an integer"'
the_matcher.failure_message_for_should.should include 'Expected errors to include "must be an integer"'
end
end

View file

@ -10,7 +10,7 @@ describe Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher do
matcher.matches?(rejecting_children).should be_false
matcher.failure_message.should == 'Expected Parent to accept nested attributes for children (is not declared)'
matcher.failure_message_for_should.should == 'Expected Parent to accept nested attributes for children (is not declared)'
end
context 'allow_destroy' do
@ -31,7 +31,7 @@ describe Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher do
matching = accepting_children(:allow_destroy => true)
matcher.allow_destroy(false).matches?(matching).should be_false
matcher.failure_message.should =~ /should not allow destroy/
matcher.failure_message_for_should.should =~ /should not allow destroy/
end
it 'rejects an invalid falsey value' do
@ -39,7 +39,7 @@ describe Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher do
matching = accepting_children(:allow_destroy => false)
matcher.allow_destroy(true).matches?(matching).should be_false
matcher.failure_message.should =~ /should allow destroy/
matcher.failure_message_for_should.should =~ /should allow destroy/
end
end
@ -53,7 +53,7 @@ describe Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher do
rejecting = accepting_children(:limit => 3)
matcher.limit(2).matches?(rejecting).should be_false
matcher.failure_message.should =~ /limit should be 2, got 3/
matcher.failure_message_for_should.should =~ /limit should be 2, got 3/
end
end
@ -73,7 +73,7 @@ describe Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher do
rejecting = accepting_children(:update_only => true)
matcher.matches?(rejecting).should be_false
matcher.failure_message.should =~ /should not be update only/
matcher.failure_message_for_should.should =~ /should not be update only/
end
it 'rejects an invalid falsey value' do
@ -81,7 +81,7 @@ describe Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher do
rejecting = accepting_children(:update_only => false)
matcher.matches?(rejecting).should be_false
matcher.failure_message.should =~ /should be update only/
matcher.failure_message_for_should.should =~ /should be update only/
end
end

View file

@ -173,7 +173,7 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher do
matcher.matches?(having_many_children).should be_false
matcher.failure_message.should =~ /does not have any relationship to conceptions/
matcher.failure_message_for_should.should =~ /does not have any relationship to conceptions/
end
it 'rejects an association that has the wrong :through option' do
@ -190,7 +190,7 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher do
matcher = have_many(:children).through(:relationships)
matcher.matches?(Parent.new).should be_false
matcher.failure_message.should =~ /through relationships, but got it through conceptions/
matcher.failure_message_for_should.should =~ /through relationships, but got it through conceptions/
end
it 'accepts an association with a valid :dependent option' do

View file

@ -29,7 +29,7 @@ describe Shoulda::Matchers::ActiveRecord::HaveReadonlyAttributeMatcher do
matcher.matches?(model)
matcher.failure_message.should_not be_nil
matcher.failure_message_for_should.should_not be_nil
end
end

View file

@ -15,7 +15,7 @@ describe Shoulda::Matchers::ActiveRecord::SerializeMatcher do
matcher.matches?(unserialized_model)
matcher.failure_message.should =~ /to serialize the attribute called :attr/
matcher.failure_message_for_should.should =~ /to serialize the attribute called :attr/
end
it 'assigns a helpful failure message when using #as' do
@ -23,7 +23,7 @@ describe Shoulda::Matchers::ActiveRecord::SerializeMatcher do
matcher.matches?(unserialized_model)
matcher.failure_message.should =~ /with a type of Hash/
matcher.failure_message_for_should.should =~ /with a type of Hash/
end
it 'assigns a helpful failure message when using #as_instance_of' do
@ -31,7 +31,7 @@ describe Shoulda::Matchers::ActiveRecord::SerializeMatcher do
matcher.matches?(unserialized_model)
matcher.failure_message.should =~ /with an instance of Hash/
matcher.failure_message_for_should.should =~ /with an instance of Hash/
end
def unserialized_model

View file

@ -79,7 +79,7 @@ describe Shoulda::Matchers::Independent::DelegateMatcher do
matcher.matches?(post_office)
message = 'Expected PostOffice#deliver_mail to delegate to PostOffice#mailman'
matcher.failure_message.should == message
matcher.failure_message_for_should.should == message
end
it 'uses the proper syntax for class methods in errors' do
@ -88,7 +88,7 @@ describe Shoulda::Matchers::Independent::DelegateMatcher do
matcher.matches?(PostOffice)
message = 'Expected PostOffice.deliver_mail to delegate to PostOffice.mailman'
matcher.failure_message.should == message
matcher.failure_message_for_should.should == message
end
end
@ -143,7 +143,7 @@ describe Shoulda::Matchers::Independent::DelegateMatcher do
matcher.matches?(post_office)
message = 'Expected PostOffice#deliver_mail to delegate to PostOffice#mailman with arguments: ["123 Nowhere Ln."]'
matcher.failure_message.should == message
matcher.failure_message_for_should.should == message
end
end
end
@ -183,7 +183,7 @@ describe Shoulda::Matchers::Independent::DelegateMatcher do
matcher.matches?(post_office)
message = 'Expected PostOffice#deliver_mail to delegate to PostOffice#mailman as #watch_tv'
matcher.failure_message.should == message
matcher.failure_message_for_should.should == message
end
end
end