]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/lib/spec/matchers/simple_matcher.rb
Show whether a trace is public or private in the trace list, so that a user can easil...
[rails.git] / vendor / gems / rspec-1.1.2 / lib / spec / matchers / simple_matcher.rb
1 module Spec
2   module Matchers
3     class SimpleMatcher
4       attr_reader :description
5       
6       def initialize(description, &match_block)
7         @description = description
8         @match_block = match_block
9       end
10
11       def matches?(actual)
12         @actual = actual
13         return @match_block.call(@actual)
14       end
15
16       def failure_message()
17         return %[expected #{@description.inspect} but got #{@actual.inspect}]
18       end
19         
20       def negative_failure_message()
21         return %[expected not to get #{@description.inspect}, but got #{@actual.inspect}]
22       end
23     end
24     
25     def simple_matcher(message, &match_block)
26       SimpleMatcher.new(message, &match_block)
27     end
28   end
29 end