Methods
public class
public instance
Public class methods
new
(name, expected=nil, &block_passed_to_init)
[show source]
# File lib/spec/matchers/matcher.rb, line 4 def initialize(name, expected=nil, &block_passed_to_init) @name = name @expected = expected @block = block_passed_to_init @messages = { :description => lambda {"#{name_to_sentence} #{expected}"}, :failure_message_for_should => lambda {|actual| "expected #{actual} to #{name_to_sentence} #{expected}"}, :failure_message_for_should_not => lambda {|actual| "expected #{actual} not to #{name_to_sentence} #{expected}"} } end
Public instance methods
description
(&block)
[show source]
# File lib/spec/matchers/matcher.rb, line 21 def description(&block) cache_or_call_cached(:description, &block) end
failure_message_for_should
(&block)
[show source]
# File lib/spec/matchers/matcher.rb, line 25 def failure_message_for_should(&block) cache_or_call_cached(:failure_message_for_should, @actual, &block) end
failure_message_for_should_not
(&block)
[show source]
# File lib/spec/matchers/matcher.rb, line 29 def failure_message_for_should_not(&block) cache_or_call_cached(:failure_message_for_should_not, @actual, &block) end
match
(&block)
[show source]
# File lib/spec/matchers/matcher.rb, line 33 def match(&block) @match_block = block end
matches?
(actual)
[show source]
# File lib/spec/matchers/matcher.rb, line 15 def matches?(actual) @actual = actual instance_exec @expected, &@block instance_exec @actual, &@match_block end