changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/autotest_matchers.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 AutotestMappingMatcher
4 def initialize(specs)
5 @specs = specs
6 end
7
8 def to(file)
9 @file = file
10 self
11 end
12
13 def matches?(autotest)
14 @autotest = prepare autotest
15 @actual = autotest.test_files_for(@file)
16 @actual == @specs
17 end
18
19 def failure_message
20 "expected #{@autotest.class} to map #{@specs.inspect} to #{@file.inspect}\ngot #{@actual.inspect}"
21 end
22
23 private
24 def prepare autotest
25 stub_found_files autotest
26 stub_find_order autotest
27 autotest
28 end
29
30 def stub_found_files autotest
31 found_files = @specs.inject({}){|h,f| h[f] = Time.at(0)}
32 autotest.stub!(:find_files).and_return(found_files)
33 end
34
35 def stub_find_order autotest
36 find_order = @specs.dup << @file
37 autotest.instance_eval { @find_order = find_order }
38 end
39
40 end
41
42 def map_specs(specs)
43 AutotestMappingMatcher.new(specs)
44 end
45
46 end
47end