Would be awesome to use proc as a message #120

Closed
wants to merge 1 commit into
from
@@ -19,6 +19,10 @@ def fail_with(message, expected=nil, actual=nil)
"appropriate failure_message_for_* method to return a string?"
end
+ if message.is_a? Proc
+ message = message.call
+ end
+
if actual && expected
if all_strings?(actual, expected)
if any_multiline_strings?(actual, expected)
@@ -66,5 +66,11 @@
RSpec::Expectations.fail_with "the message", lambda {}, lambda {}
}.should fail_with("the message")
end
+
+ it "accept message as Proc" do
+ lambda {
+ RSpec::Expectations.fail_with lambda { "the message"}
+ }.should fail_with("the message")
+ end
end