lib/rspec/matchers/built_in/yield.rb in rspec-expectations-2.11.3 vs lib/rspec/matchers/built_in/yield.rb in rspec-expectations-2.12.0

- old
+ new

@@ -81,11 +81,11 @@ class YieldWithNoArgs < BaseMatcher def matches?(block) @probe = YieldProbe.probe(block) - @probe.yielded_once?(:yield_with_no_args) && @probe.single_yield_args.none? + @probe.yielded_once?(:yield_with_no_args) && @probe.single_yield_args.empty? end def failure_message_for_should "expected given block to yield with no arguments, but #{failure_reason}" end @@ -125,11 +125,11 @@ "expected given block not to yield with arguments, but #{negative_failure_reason}" end def description desc = "yield with args" - desc << "(" + @expected.map { |e| e.inspect }.join(", ") + ")" if @expected.any? + desc << "(" + @expected.map { |e| e.inspect }.join(", ") + ")" unless @expected.empty? desc end private @@ -150,12 +150,12 @@ "did" end end def args_match? - if @expected.none? # expect {...}.to yield_with_args - @positive_args_failure = "yielded with no arguments" if @actual.none? - return @actual.any? + if @expected.empty? # expect {...}.to yield_with_args + @positive_args_failure = "yielded with no arguments" if @actual.empty? + return !@actual.empty? end unless match = all_args_match? @positive_args_failure = "yielded with unexpected arguments" + "\nexpected: #{@expected.inspect}" +