Skip to content

Commit

Permalink
Remove diffability from yield matchers for now.
Browse files Browse the repository at this point in the history
I'm not sure it makes sense given that they don't match strictly but instead match using === or ==.
  • Loading branch information
myronmarston committed Mar 31, 2012
1 parent 1897250 commit 3c6a81e
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions lib/rspec/matchers/built_in/yield.rb
Expand Up @@ -44,7 +44,6 @@ def failure_reason
end

class YieldWithArgs
attr_reader :expected, :actual
def initialize(*args)
@expected = args
end
Expand All @@ -63,10 +62,6 @@ def failure_message_for_should_not
"expected given block not to yield with arguments, but #{negative_failure_reason}"
end

def diffable?
true
end

private

def positive_failure_reason
Expand All @@ -80,8 +75,8 @@ def positive_failure_reason
def negative_failure_reason
if all_args_match?
"yielded with expected arguments" +
"\nexpected not: #{expected.inspect}" +
"\n got: #{actual.inspect} (compared using === and ==)"
"\nexpected not: #{@expected.inspect}" +
"\n got: #{@actual.inspect} (compared using === and ==)"
else
"did"
end
Expand All @@ -95,8 +90,8 @@ def args_match?

unless match = all_args_match?
@positive_args_failure = "yielded with unexpected arguments" +
"\nexpected: #{expected.inspect}" +
"\n got: #{actual.inspect} (compared using === and ==)"
"\nexpected: #{@expected.inspect}" +
"\n got: #{@actual.inspect} (compared using === and ==)"
end

match
Expand All @@ -112,8 +107,6 @@ def all_args_match?
end

class YieldSuccessiveArgs
attr_reader :expected, :actual

def initialize(*args)
@expected = args
@actual = []
Expand All @@ -126,14 +119,14 @@ def matches?(block)

def failure_message_for_should
"expected given block to yield successively with arguments, but yielded with unexpected arguments" +
"\nexpected: #{expected.inspect}" +
"\n got: #{actual.inspect} (compared using === and ==)"
"\nexpected: #{@expected.inspect}" +
"\n got: #{@actual.inspect} (compared using === and ==)"
end

def failure_message_for_should_not
"expected given block not to yield successively with arguments, but yielded with expected arguments" +
"\nexpected not: #{expected.inspect}" +
"\n got: #{actual.inspect} (compared using === and ==)"
"\nexpected not: #{@expected.inspect}" +
"\n got: #{@actual.inspect} (compared using === and ==)"
end

private
Expand Down

0 comments on commit 3c6a81e

Please sign in to comment.