rr 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/Rakefile +1 -1
- data/examples/rr/double_bind_example.rb +3 -3
- data/examples/rr/double_dispatching_example.rb +32 -0
- data/examples/rr/double_reset_example.rb +2 -2
- data/examples/rr/space_create_example.rb +1 -1
- data/examples/rr/space_reset_example.rb +2 -2
- data/examples/rr/space_verify_example.rb +4 -4
- data/lib/rr/double.rb +1 -1
- metadata +2 -2
data/CHANGES
CHANGED
data/Rakefile
CHANGED
@@ -13,13 +13,13 @@ describe Double, "#bind with an existing method" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "overrides the original method with the double's dispatching methods" do
|
16
|
-
@object.respond_to?(:
|
16
|
+
@object.respond_to?(:__rr__foobar).should == false
|
17
17
|
@double.bind
|
18
|
-
@object.respond_to?(:
|
18
|
+
@object.respond_to?(:__rr__foobar).should == true
|
19
19
|
|
20
20
|
rr_foobar_called = false
|
21
21
|
(class << @object; self; end).class_eval do
|
22
|
-
define_method :
|
22
|
+
define_method :__rr__foobar do
|
23
23
|
rr_foobar_called = true
|
24
24
|
end
|
25
25
|
end
|
@@ -12,6 +12,38 @@ describe Double, "method dispatching", :shared => true do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
describe Double, " method dispatching where method name has a ! in it" do
|
16
|
+
before do
|
17
|
+
@space = Space.new
|
18
|
+
@object = Object.new
|
19
|
+
@method_name = :foobar!
|
20
|
+
@object.methods.should_not include(@method_name.to_s)
|
21
|
+
@double = @space.create_double(@object, @method_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "executes the block" do
|
25
|
+
scenario = @space.create_scenario(@double)
|
26
|
+
scenario.with(1, 2) {:return_value}
|
27
|
+
@object.foobar!(1, 2).should == :return_value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe Double, " method dispatching where method name has a ? in it" do
|
32
|
+
before do
|
33
|
+
@space = Space.new
|
34
|
+
@object = Object.new
|
35
|
+
@method_name = :foobar?
|
36
|
+
@object.methods.should_not include(@method_name.to_s)
|
37
|
+
@double = @space.create_double(@object, @method_name)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "executes the block" do
|
41
|
+
scenario = @space.create_scenario(@double)
|
42
|
+
scenario.with(1, 2) {:return_value}
|
43
|
+
@object.foobar?(1, 2).should == :return_value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
15
47
|
describe Double, " method dispatching where the scenario takes a block" do
|
16
48
|
it_should_behave_like "RR::Double method dispatching"
|
17
49
|
|
@@ -5,10 +5,10 @@ module RR
|
|
5
5
|
describe Double, "#reset", :shared => true do
|
6
6
|
it "cleans up by removing the __rr__ method" do
|
7
7
|
@double.bind
|
8
|
-
@object.methods.should include("
|
8
|
+
@object.methods.should include("__rr__foobar")
|
9
9
|
|
10
10
|
@double.reset
|
11
|
-
@object.methods.should_not include("
|
11
|
+
@object.methods.should_not include("__rr__foobar")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -154,7 +154,7 @@ describe Space, "#create_double when double does not exist" do
|
|
154
154
|
|
155
155
|
it "overrides the method when passing a block" do
|
156
156
|
double = @space.create_double(@object, @method_name)
|
157
|
-
@object.methods.should include("__rr__#{@method_name}
|
157
|
+
@object.methods.should include("__rr__#{@method_name}")
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
@@ -14,11 +14,11 @@ describe Space, "#reset_double" do
|
|
14
14
|
it "resets the doubles" do
|
15
15
|
double = @space.create_double(@object, @method_name)
|
16
16
|
@space.doubles[@object][@method_name].should === double
|
17
|
-
@object.methods.should include("__rr__#{@method_name}
|
17
|
+
@object.methods.should include("__rr__#{@method_name}")
|
18
18
|
|
19
19
|
@space.reset_double(@object, @method_name)
|
20
20
|
@space.doubles[@object][@method_name].should be_nil
|
21
|
-
@object.methods.should_not include("__rr__#{@method_name}
|
21
|
+
@object.methods.should_not include("__rr__#{@method_name}")
|
22
22
|
end
|
23
23
|
|
24
24
|
it "removes the object from the doubles map when it has no doubles" do
|
@@ -56,7 +56,7 @@ describe Space, "#verify_double" do
|
|
56
56
|
it "verifies and deletes the double" do
|
57
57
|
double = @space.create_double(@object, @method_name)
|
58
58
|
@space.doubles[@object][@method_name].should === double
|
59
|
-
@object.methods.should include("__rr__#{@method_name}
|
59
|
+
@object.methods.should include("__rr__#{@method_name}")
|
60
60
|
|
61
61
|
verify_calls = 0
|
62
62
|
(class << double; self; end).class_eval do
|
@@ -68,13 +68,13 @@ describe Space, "#verify_double" do
|
|
68
68
|
verify_calls.should == 1
|
69
69
|
|
70
70
|
@space.doubles[@object][@method_name].should be_nil
|
71
|
-
@object.methods.should_not include("__rr__#{@method_name}
|
71
|
+
@object.methods.should_not include("__rr__#{@method_name}")
|
72
72
|
end
|
73
73
|
|
74
74
|
it "deletes the double when verifying the double raises an error" do
|
75
75
|
double = @space.create_double(@object, @method_name)
|
76
76
|
@space.doubles[@object][@method_name].should === double
|
77
|
-
@object.methods.should include("__rr__#{@method_name}
|
77
|
+
@object.methods.should include("__rr__#{@method_name}")
|
78
78
|
|
79
79
|
verify_called = true
|
80
80
|
(class << double; self; end).class_eval do
|
@@ -87,7 +87,7 @@ describe Space, "#verify_double" do
|
|
87
87
|
verify_called.should be_true
|
88
88
|
|
89
89
|
@space.doubles[@object][@method_name].should be_nil
|
90
|
-
@object.methods.should_not include("__rr__#{@method_name}
|
90
|
+
@object.methods.should_not include("__rr__#{@method_name}")
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
data/lib/rr/double.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.3
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rr
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-07-
|
6
|
+
version: 0.1.3
|
7
|
+
date: 2007-07-09 00:00:00 -07:00
|
8
8
|
summary: RR (Double Ruby) is a double framework that features a rich selection of double techniques and a terse syntax. http://xunitpatterns.com/Test%20Double.html
|
9
9
|
require_paths:
|
10
10
|
- lib
|