method

simple_matcher

simple_matcher(message, &match_block)
public

No documentation available.

# File lib/spec/matchers/simple_matcher.rb, line 25
    def simple_matcher(message, &match_block)
      SimpleMatcher.new(message, &match_block)
    end

1Note

Example using simple_matcher

ckozus · Sep 27, 20083 thanks

This is extracted from: http://blog.davidchelimsky.net/2008/6/7/thoughts-on-the-dance-off

Here's an example:

def be_sorted
simple_matcher("a sorted list") {|actual| actual.sort == actual}
end
[1,2,3].should be_sorted

The block is handed the actual value. If the block returns true, the expectation passes. If it returns false, it fails with the following message:

expected "a sorted list" but got [1, 3, 2]

If you say [1,2,3].should_not be_sorted you’d get this message instead=:

expected not to get "a sorted list", but got [1, 2, 3]

As of now, you don’t get any control over the failure message other than the string you pass to the simple_matcher method[...]