changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/lib/spec/matchers/simple_matcher.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1module 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
29end