Included Modules

Matchy::MatcherBuilder

Public Class Methods

matcher_name() click to toggle source
    # File lib/matchy/matcher_builder.rb, line 14
14:         def self.matcher_name
15:           @matcher_name
16:         end
new(match_block, test_case) click to toggle source
    # File lib/matchy/matcher_builder.rb, line 21
21:         def initialize(match_block, test_case)
22:           @match_block, @test_case = match_block, test_case
23:           @matcher_name = self.class.matcher_name
24:         end

Public Instance Methods

build_matcher(matcher_name=nil, args=[], &block) click to toggle source
    # File lib/matchy/matcher_builder.rb, line 5
 5:     def build_matcher(matcher_name=nil, args=[], &block)
 6:       match_block = lambda do |actual, matcher|
 7:         block.call(actual, matcher, args)
 8:       end
 9:       
10:       body = lambda do |klass|
11:         include Test::Unit::Assertions
12:         @matcher_name = matcher_name.to_s
13:         
14:         def self.matcher_name
15:           @matcher_name
16:         end
17: 
18:         attr_reader :matcher_name
19:         attr_accessor :positive_failure_message, :negative_failure_message, :chained_messages
20:         
21:         def initialize(match_block, test_case)
22:           @match_block, @test_case = match_block, test_case
23:           @matcher_name = self.class.matcher_name
24:         end
25: 
26:         def method_missing(id, *args, &block)
27:           (self.chained_messages ||= []) << ChainedMessage.new(id, args, block)
28:           self
29:         end
30: 
31:         def matches?(given)
32:           @positive_failure_message ||= "Matching with '#{matcher_name}' failed, although it should match."
33:           @negative_failure_message ||= "Matching with '#{matcher_name}' passed, although it should_not match."
34:           @match_block.call(given, self)
35:         end
36:         
37:         def fail!(which)
38:           @test_case.flunk(which ? failure_message : negative_failure_message)
39:         end
40: 
41:         def pass!(which)
42:           @test_case.assert true
43:         end
44:         
45:         alias_method :failure_message, :positive_failure_message
46:       end
47:       
48:       Class.new(&body).new(match_block, self)
49:     end
fail!(which) click to toggle source
    # File lib/matchy/matcher_builder.rb, line 37
37:         def fail!(which)
38:           @test_case.flunk(which ? failure_message : negative_failure_message)
39:         end
matches?(given) click to toggle source
    # File lib/matchy/matcher_builder.rb, line 31
31:         def matches?(given)
32:           @positive_failure_message ||= "Matching with '#{matcher_name}' failed, although it should match."
33:           @negative_failure_message ||= "Matching with '#{matcher_name}' passed, although it should_not match."
34:           @match_block.call(given, self)
35:         end
method_missing(id, *args, &block) click to toggle source
    # File lib/matchy/matcher_builder.rb, line 26
26:         def method_missing(id, *args, &block)
27:           (self.chained_messages ||= []) << ChainedMessage.new(id, args, block)
28:           self
29:         end
pass!(which) click to toggle source
    # File lib/matchy/matcher_builder.rb, line 41
41:         def pass!(which)
42:           @test_case.assert true
43:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.