# File lib/spec/matchers/matcher.rb, line 10 def initialize(name, *expected, &declarations) @name = name @expected = expected @actual = nil @diffable = false @expected_exception = nil @messages = { :description => lambda {"#{name_to_sentence}#{expected_to_sentence}"}, :failure_message_for_should => lambda {|actual| "expected #{actual.inspect} to #{name_to_sentence}#{expected_to_sentence}"}, :failure_message_for_should_not => lambda {|actual| "expected #{actual.inspect} not to #{name_to_sentence}#{expected_to_sentence}"} } making_declared_methods_public do instance_exec(*@expected, &declarations) end end
See Spec::Matchers
# File lib/spec/matchers/matcher.rb, line 82 def chain(method, &block) self.class.class_eval do define_method method do |*args| block.call(*args) self end end end
See Spec::Matchers
# File lib/spec/matchers/matcher.rb, line 67 def description(&block) cache_or_call_cached(:description, &block) end
See Spec::Matchers
# File lib/spec/matchers/matcher.rb, line 77 def diffable @diffable = true end
Used internally by objects returns by should and should_not.
# File lib/spec/matchers/matcher.rb, line 72 def diffable? @diffable end
See Spec::Matchers
# File lib/spec/matchers/matcher.rb, line 57 def failure_message_for_should(&block) cache_or_call_cached(:failure_message_for_should, &block) end
See Spec::Matchers
# File lib/spec/matchers/matcher.rb, line 62 def failure_message_for_should_not(&block) cache_or_call_cached(:failure_message_for_should_not, &block) end
See Spec::Matchers
# File lib/spec/matchers/matcher.rb, line 46 def match(&block) @match_block = block end
See Spec::Matchers
# File lib/spec/matchers/matcher.rb, line 51 def match_unless_raises(exception=Exception, &block) @expected_exception = exception match(&block) end
Used internally by objects returns by should and should_not.
# File lib/spec/matchers/matcher.rb, line 27 def matches?(actual) @actual = actual if @expected_exception begin instance_exec(actual, &@match_block) true rescue @expected_exception false end else begin instance_exec(actual, &@match_block) rescue Spec::Expectations::ExpectationNotMetError false end end end
Generated with the Darkfish Rdoc Generator 2.