Methods
public class
public instance
Attributes
| description | [W] | |
| failure_message | [W] | |
| negative_failure_message | [W] |
Public class methods
new
(description, &match_block)
[show source]
# File lib/spec/matchers/simple_matcher.rb, line 6 def initialize(description, &match_block) @description = description @match_block = match_block @failure_message = @negative_failure_message = nil end
Public instance methods
description
()
[show source]
# File lib/spec/matchers/simple_matcher.rb, line 22 def description @description || explanation end
explanation
()
[show source]
# File lib/spec/matchers/simple_matcher.rb, line 34 def explanation "No description provided. See RDoc for simple_matcher()" end
failure_message
()
[show source]
# File lib/spec/matchers/simple_matcher.rb, line 26 def failure_message @failure_message || (@description.nil? ? explanation : %[expected #{@description.inspect} but got #{@given.inspect}]) end
matches?
(given)
[show source]
# File lib/spec/matchers/simple_matcher.rb, line 12 def matches?(given) @given = given case @match_block.arity when 2 @match_block.call(@given, self) else @match_block.call(@given) end end
negative_failure_message
()
[show source]
# File lib/spec/matchers/simple_matcher.rb, line 30 def negative_failure_message @negative_failure_message || (@description.nil? ? explanation : %[expected not to get #{@description.inspect}, but got #{@given.inspect}]) end