Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 33 lines (27 sloc) 0.875 kB
8c27e78 got rid of the test/unit output in TextMate
dchelimsky authored
1 module Spec
2 module Matchers
3 class SimpleMatcher
7e1a719 @dchelimsky simple_matcher refactoring - one more time - much simpler
authored
4 attr_accessor :description
5 attr_writer :failure_message, :negative_failure_message
6
8c27e78 got rid of the test/unit output in TextMate
dchelimsky authored
7 def initialize(description, &match_block)
7e1a719 @dchelimsky simple_matcher refactoring - one more time - much simpler
authored
8 @description = description
8c27e78 got rid of the test/unit output in TextMate
dchelimsky authored
9 @match_block = match_block
10 end
11
12 def matches?(actual)
13 @actual = actual
8ec1fa1 @dchelimsky simple_matcher refactoring
authored
14 @match_block.arity == 2 ?
7e1a719 @dchelimsky simple_matcher refactoring - one more time - much simpler
authored
15 @match_block.call(@actual, self) :
8ec1fa1 @dchelimsky simple_matcher refactoring
authored
16 @match_block.call(@actual)
8c27e78 got rid of the test/unit output in TextMate
dchelimsky authored
17 end
18
b18a896 @dchelimsky more simple matching refactoring
authored
19 def failure_message
7e1a719 @dchelimsky simple_matcher refactoring - one more time - much simpler
authored
20 @failure_message || %[expected #{@description.inspect} but got #{@actual.inspect}]
8c27e78 got rid of the test/unit output in TextMate
dchelimsky authored
21 end
7e1a719 @dchelimsky simple_matcher refactoring - one more time - much simpler
authored
22
b18a896 @dchelimsky more simple matching refactoring
authored
23 def negative_failure_message
7e1a719 @dchelimsky simple_matcher refactoring - one more time - much simpler
authored
24 @negative_failure_message || %[expected not to get #{@description.inspect}, but got #{@actual.inspect}]
fa9952c @dchelimsky added messenger to simple_matcher for custom failure messages
authored
25 end
26
27 end
b18a896 @dchelimsky more simple matching refactoring
authored
28
29 def simple_matcher(message, &match_block)
30 SimpleMatcher.new(message, &match_block)
31 end
8c27e78 got rid of the test/unit output in TextMate
dchelimsky authored
32 end
33 end
Something went wrong with that request. Please try again.