Permalink
Browse files

fixes #108 : RSpec 2.10 compatibility

  • Loading branch information...
1 parent f7337c6 commit 875cd9a21ba1b32b70638100c5714bf4ffbb7fc3 Brian Shaver committed Jan 8, 2013
Showing with 115 additions and 115 deletions.
  1. +7 −7 lib/shoulda/matchers/action_controller/assign_to_matcher.rb
  2. +2 −2 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
  3. +3 −3 lib/shoulda/matchers/action_controller/redirect_to_matcher.rb
  4. +3 −3 lib/shoulda/matchers/action_controller/render_template_matcher.rb
  5. +2 −2 lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb
  6. +2 −2 lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb
  7. +2 −2 lib/shoulda/matchers/action_controller/respond_with_matcher.rb
  8. +4 −4 lib/shoulda/matchers/action_controller/route_matcher.rb
  9. +2 −2 lib/shoulda/matchers/action_controller/set_session_matcher.rb
  10. +3 −3 lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb
  11. +2 −2 lib/shoulda/matchers/action_mailer/have_sent_email_matcher.rb
  12. +6 −6 lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb
  13. +2 −2 lib/shoulda/matchers/active_model/allow_value_matcher.rb
  14. +2 −2 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
  15. +1 −1 lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb
  16. +2 −2 lib/shoulda/matchers/active_model/only_integer_matcher.rb
  17. +2 −2 lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb
  18. +3 −3 lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb
  19. +7 −7 lib/shoulda/matchers/active_model/validation_matcher.rb
  20. +2 −2 lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb
  21. +2 −2 lib/shoulda/matchers/active_record/association_matcher.rb
  22. +2 −2 lib/shoulda/matchers/active_record/have_db_column_matcher.rb
  23. +2 −2 lib/shoulda/matchers/active_record/have_db_index_matcher.rb
  24. +4 −4 lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb
  25. +2 −2 lib/shoulda/matchers/active_record/query_the_database_matcher.rb
  26. +2 −2 lib/shoulda/matchers/active_record/serialize_matcher.rb
  27. +1 −1 lib/shoulda/matchers/independent/delegate_matcher.rb
  28. +1 −1 spec/shoulda/matchers/action_controller/assign_to_matcher_spec.rb
  29. +1 −1 spec/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
  30. +16 −16 spec/shoulda/matchers/action_mailer/have_sent_email_spec.rb
  31. +1 −1 spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb
  32. +1 −1 spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb
  33. +2 −2 spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb
  34. +1 −1 spec/shoulda/matchers/active_model/only_integer_matcher_spec.rb
  35. +2 −2 spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb
  36. +6 −6 spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb
  37. +2 −2 spec/shoulda/matchers/active_record/association_matcher_spec.rb
  38. +1 −1 spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb
  39. +3 −3 spec/shoulda/matchers/active_record/serialize_matcher_spec.rb
  40. +4 −4 spec/shoulda/matchers/independent/delegate_matcher_spec.rb
@@ -19,7 +19,7 @@ def assign_to(variable)
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 @@ def in_context(context)
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 @@ def assigned_value?
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 @@ def kind_of_expected_class?
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
@@ -19,11 +19,11 @@ def matches?(controller)
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
@@ -12,7 +12,7 @@ def redirect_to(url_or_description, &block)
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 @@ def description
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
@@ -20,7 +20,7 @@ def render_template(options = {}, message = nil)
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 @@ def in_context(context)
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
@@ -33,11 +33,11 @@ def matches?(controller)
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
@@ -35,11 +35,11 @@ def matches?(controller)
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
@@ -30,11 +30,11 @@ def matches?(controller)
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
@@ -33,7 +33,7 @@ def initialize(method, path, context)
@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 @@ def route_recognized?
{ :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
@@ -32,11 +32,11 @@ def matches?(controller)
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
@@ -22,7 +22,7 @@ def initialize
@options = {}
end
- attr_reader :failure_message, :negative_failure_message
+ attr_reader :failure_message_for_should, :failure_message_for_should_not
def to(value)
if !value.is_a?(String) && !value.is_a?(Regexp)
@@ -53,11 +53,11 @@ def description
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
@@ -106,11 +106,11 @@ def matches?(subject)
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
@@ -16,7 +16,7 @@ def allow_mass_assignment_of(value)
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,22 +35,22 @@ def matches?(subject)
@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
end
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
@@ -60,11 +60,11 @@ def matches?(instance)
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
@@ -20,8 +20,8 @@ def with_message(message)
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
@@ -88,7 +88,7 @@ def matches?(subject)
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
@@ -24,8 +24,8 @@ def allowed_types
'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
@@ -48,7 +48,7 @@ def description
"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 @@ def submatchers_match?
end
def submatcher_failure_messages
- failing_submatchers.map(&:failure_message)
+ failing_submatchers.map(&:failure_message_for_should)
end
def failing_submatchers
@@ -97,7 +97,7 @@ def set_scoped_attributes
@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
@@ -134,11 +134,11 @@ def validate_after_scope_change?
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
@@ -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 @@ def strict
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 @@ def allows_value_of(value, message = nil)
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 @@ def disallows_value_of(value, message = nil)
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
Oops, something went wrong.

0 comments on commit 875cd9a

Please sign in to comment.