rr 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ * 0.1.3
2
+ - Fixed issue where Double#placeholder_name issues when Double method name has a ! or ?
3
+
1
4
  * 0.1.2
2
5
  - Scenario#returns also accepts an argument
3
6
  - Implemented Scenario#yields
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ def run_suite
21
21
  end
22
22
 
23
23
  PKG_NAME = "rr"
24
- PKG_VERSION = "0.1.2"
24
+ PKG_VERSION = "0.1.3"
25
25
  PKG_FILES = FileList[
26
26
  '[A-Z]*',
27
27
  '*.rb',
@@ -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?(:__rr__foobar__rr__).should == false
16
+ @object.respond_to?(:__rr__foobar).should == false
17
17
  @double.bind
18
- @object.respond_to?(:__rr__foobar__rr__).should == true
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 :__rr__foobar__rr__ do
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("__rr__foobar__rr__")
8
+ @object.methods.should include("__rr__foobar")
9
9
 
10
10
  @double.reset
11
- @object.methods.should_not include("__rr__foobar__rr__")
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}__rr__")
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}__rr__")
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}__rr__")
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}__rr__")
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}__rr__")
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}__rr__")
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}__rr__")
90
+ @object.methods.should_not include("__rr__#{@method_name}")
91
91
  end
92
92
  end
93
93
 
data/lib/rr/double.rb CHANGED
@@ -81,7 +81,7 @@ module RR
81
81
  end
82
82
 
83
83
  def placeholder_name
84
- "__rr__#{@method_name}__rr__"
84
+ "__rr__#{@method_name}"
85
85
  end
86
86
 
87
87
  def meta
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.2
7
- date: 2007-07-08 00:00:00 -07:00
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