rr 0.9.0 → 0.10.0

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,7 @@
1
+ * 0.10.0
2
+ - Method is no longer invoked if respond_to? returns false. This was in place to support ActiveRecord association proxies, and is no longer needed.
3
+
4
+ * 0.9.0
1
5
  - instance_of Doubles now apply to methods invoked in the subject's #initialize method.
2
6
 
3
7
  * 0.8.1
data/README.rdoc CHANGED
@@ -32,7 +32,7 @@ Currently RR implements mocks, stubs, proxies, and spies. Fakes usually require
32
32
  end
33
33
 
34
34
  === rspec
35
- Spec::Runners.configure do |config|
35
+ Spec::Runner.configure do |config|
36
36
  config.mock_with :rr
37
37
  # or if that doesn't work due to a version incompatibility
38
38
  # config.mock_with RR::Adapters::Rspec
@@ -316,7 +316,7 @@ to making it possible. We all are standing on the shoulders of giants.
316
316
  * Aslak Hellesoy for Developing Rspec
317
317
  * Dan North for syntax ideas
318
318
  * Dave Astels for some BDD inspiration
319
- * David Chelimsky for encouragement to make the RR framework, for developing the Rspec mock framework, and syntax ideas
319
+ * David Chelimsky for encouragement to make the RR framework, for developing the Rspec mock framework, syntax ideas, and patches
320
320
  * Daniel Sudol for identifing performance issues with RR
321
321
  * Felix Morio for pairing with me
322
322
  * Gerard Meszaros for his excellent book "xUnit Test Patterns"
@@ -324,7 +324,7 @@ to making it possible. We all are standing on the shoulders of giants.
324
324
  * Jeff Whitmire for documentation suggestions
325
325
  * Jim Weirich for developing Flexmock, the first Terse ruby mock framework in Ruby
326
326
  * Joe Ferris for patches
327
- * Matthew O'Conner for patches
327
+ * Matthew O'Connor for patches and pairing with me
328
328
  * Michael Niessner for patches and pairing with me
329
329
  * Mike Mangino (from Elevated Rails) for patches and pairing with me
330
330
  * Nick Kallen for documentation suggestions, bug reports, and patches
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :major: 0
3
- :minor: 9
2
+ :minor: 10
4
3
  :patch: 0
4
+ :major: 0
@@ -50,7 +50,7 @@ module RR
50
50
  # that succeeds when passed an argument of a certain type.
51
51
  # mock(object).method_name(is_a(String)) {return_value}
52
52
  # object.method_name("A String") # passes
53
- def is_a(klass)
53
+ def is_a(klass)
54
54
  RR::WildcardMatchers::IsA.new(klass)
55
55
  end
56
56
 
data/lib/rr/double.rb CHANGED
@@ -135,12 +135,12 @@ module RR
135
135
  end
136
136
 
137
137
  def verify_method_signature
138
- raise RR::Errors::SubjectDoesNotImplementMethodError unless definition.subject.respond_to?(double_injection.send(:original_method_name))
138
+ raise RR::Errors::SubjectDoesNotImplementMethodError unless definition.subject.respond_to?(double_injection.send(:original_method_alias_name))
139
139
  raise RR::Errors::SubjectHasDifferentArityError unless arity_matches?
140
140
  end
141
141
 
142
142
  def subject_arity
143
- definition.subject.method(double_injection.send(:original_method_name)).arity
143
+ definition.subject.method(double_injection.send(:original_method_alias_name)).arity
144
144
  end
145
145
 
146
146
  def subject_accepts_only_varargs?
@@ -5,21 +5,14 @@ module RR
5
5
  class DoubleInjection
6
6
  include Space::Reader
7
7
  MethodArguments = Struct.new(:arguments, :block)
8
- attr_reader :subject, :method_name, :doubles
9
-
10
- def initialize(subject, method_name)
8
+ attr_reader :subject, :method_name, :doubles, :subject_class
9
+
10
+ def initialize(subject, method_name, subject_class)
11
11
  @subject = subject
12
+ @subject_class = subject_class
12
13
  @method_name = method_name.to_sym
13
14
  if object_has_method?(method_name)
14
- begin
15
- meta.__send__(:alias_method, original_method_name, method_name)
16
- rescue NameError => e
17
- begin
18
- subject.send(method_name)
19
- meta.__send__(:alias_method, original_method_name, method_name)
20
- rescue NameError => e
21
- end
22
- end
15
+ subject_class.__send__(:alias_method, original_method_alias_name, method_name)
23
16
  end
24
17
  @doubles = []
25
18
  end
@@ -34,14 +27,13 @@ module RR
34
27
  # that dispatches to the matching Double when the method
35
28
  # is called.
36
29
  def bind
37
- define_implementation_placeholder
38
30
  returns_method = <<-METHOD
39
31
  def #{@method_name}(*args, &block)
40
32
  arguments = MethodArguments.new(args, block)
41
- __send__('#{placeholder_name}', arguments)
33
+ RR::Space.double_injection(self, :#{@method_name}).call_method(arguments.arguments, arguments.block)
42
34
  end
43
35
  METHOD
44
- meta.class_eval(returns_method, __FILE__, __LINE__ - 5)
36
+ subject_class.class_eval(returns_method, __FILE__, __LINE__ - 5)
45
37
  self
46
38
  end
47
39
 
@@ -57,29 +49,20 @@ module RR
57
49
  # It binds the original method implementation on the subject
58
50
  # if one exists.
59
51
  def reset
60
- meta.__send__(:remove_method, placeholder_name)
61
52
  if object_has_original_method?
62
- meta.__send__(:alias_method, @method_name, original_method_name)
63
- meta.__send__(:remove_method, original_method_name)
53
+ subject_class.__send__(:alias_method, @method_name, original_method_alias_name)
54
+ subject_class.__send__(:remove_method, original_method_alias_name)
64
55
  else
65
- meta.__send__(:remove_method, @method_name)
56
+ subject_class.__send__(:remove_method, @method_name)
66
57
  end
67
58
  end
68
59
 
69
60
  def call_original_method(*args, &block)
70
- @subject.__send__(original_method_name, *args, &block)
61
+ @subject.__send__(original_method_alias_name, *args, &block)
71
62
  end
72
63
 
73
64
  def object_has_original_method?
74
- object_has_method?(original_method_name)
75
- end
76
-
77
- protected
78
- def define_implementation_placeholder
79
- me = self
80
- meta.__send__(:define_method, placeholder_name) do |arguments|
81
- me.__send__(:call_method, arguments.arguments, arguments.block)
82
- end
65
+ object_has_method?(original_method_alias_name)
83
66
  end
84
67
 
85
68
  def call_method(args, block)
@@ -90,7 +73,8 @@ module RR
90
73
  double_not_found_error(*args)
91
74
  end
92
75
  end
93
-
76
+
77
+ protected
94
78
  def find_double_to_attempt(args)
95
79
  matches = DoubleMatches.new(@doubles).find_all_matches(args)
96
80
 
@@ -127,20 +111,12 @@ module RR
127
111
  raise Errors::DoubleNotFoundError, message
128
112
  end
129
113
 
130
- def placeholder_name
131
- "__rr__#{@method_name}"
132
- end
133
-
134
- def original_method_name
114
+ def original_method_alias_name
135
115
  "__rr__original_#{@method_name}"
136
116
  end
137
117
 
138
118
  def object_has_method?(method_name)
139
119
  @subject.methods.include?(method_name.to_s) || @subject.respond_to?(method_name)
140
120
  end
141
-
142
- def meta
143
- (class << @subject; self; end)
144
- end
145
121
  end
146
122
  end
data/lib/rr/space.rb CHANGED
@@ -34,7 +34,7 @@ module RR
34
34
  # subject.
35
35
  def double_injection(subject, method_name)
36
36
  @double_injections[subject][method_name.to_sym] ||= begin
37
- DoubleInjection.new(subject, method_name.to_sym).bind
37
+ DoubleInjection.new(subject, method_name.to_sym, (class << subject; self; end)).bind
38
38
  end
39
39
  end
40
40
 
@@ -3,40 +3,31 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
3
3
  module RR
4
4
  module DoubleDefinitions
5
5
  describe DoubleInjection do
6
+ attr_reader :subject, :method_name, :double_injection, :original_method
6
7
  describe "#bind" do
7
8
  context "with an existing method" do
8
9
  before do
9
10
  @subject = Object.new
10
11
  @method_name = :foobar
11
- def @subject.foobar;
12
+ def subject.foobar;
12
13
  :original_foobar;
13
14
  end
14
- @original_method = @subject.method(@method_name)
15
- @subject.methods.should include(@method_name.to_s)
16
- @double_injection = DoubleInjection.new(@subject, @method_name)
17
- end
15
+ @original_method = @subject.method(method_name)
16
+ @subject.methods.should include(method_name.to_s)
18
17
 
19
- it "overrides the original method with the double_injection's dispatching methods" do
20
- @subject.respond_to?(:__rr__foobar).should == false
21
- @double_injection.bind
22
- @subject.respond_to?(:__rr__foobar).should == true
18
+ subject.method(:foobar).should == original_method
23
19
 
24
- rr_foobar_called = false
25
- (class << @subject; self; end).class_eval do
26
- define_method :__rr__foobar do
27
- rr_foobar_called = true
28
- end
29
- end
20
+ @double_injection = RR::Space.double_injection(subject, method_name)
21
+ end
30
22
 
31
- rr_foobar_called.should == false
32
- @subject.foobar
33
- rr_foobar_called.should == true
23
+ it "overrides the original method with the double_injection's dispatching methods" do
24
+ double_injection.bind
25
+ subject.method(:foobar).should_not == original_method
34
26
  end
35
27
 
36
- it "stores original method in __rr__original_method_name" do
37
- @double_injection.bind
38
- @subject.respond_to?(:__rr__original_foobar).should == true
39
- @subject.method(:__rr__original_foobar).should == @original_method
28
+ it "stores original method in __rr__original_method_alias_name" do
29
+ subject.respond_to?(:__rr__original_foobar).should == true
30
+ subject.method(:__rr__original_foobar).should == original_method
40
31
  end
41
32
  end
42
33
 
@@ -44,30 +35,16 @@ module RR
44
35
  before do
45
36
  @subject = Object.new
46
37
  @method_name = :foobar
47
- @subject.methods.should_not include(@method_name.to_s)
48
- @double_injection = DoubleInjection.new(@subject, @method_name)
38
+ subject.methods.should_not include(method_name.to_s)
39
+ RR::Space.double_injection(subject, method_name)
49
40
  end
50
41
 
51
42
  it "creates a new method with the double_injection's dispatching methods" do
52
- @subject.respond_to?(:__rr__foobar).should == false
53
- @double_injection.bind
54
- @subject.respond_to?(:__rr__foobar).should == true
55
-
56
- rr_foobar_called = false
57
- (class << @subject; self; end).class_eval do
58
- define_method :__rr__foobar do
59
- rr_foobar_called = true
60
- end
61
- end
62
-
63
- rr_foobar_called.should == false
64
- @subject.foobar
65
- rr_foobar_called.should == true
43
+ subject.method(method_name).should_not be_nil
66
44
  end
67
45
 
68
- it "does not create method __rr__original_method_name" do
69
- @double_injection.bind
70
- @subject.respond_to?(:__rr__original_foobar).should == false
46
+ it "does not create method __rr__original_method_alias_name" do
47
+ subject.respond_to?(:__rr__original_foobar).should == false
71
48
  end
72
49
  end
73
50
 
@@ -75,34 +52,19 @@ module RR
75
52
  before do
76
53
  @subject = Object.new
77
54
  @method_name = :'=='
78
- @subject.should respond_to(@method_name)
79
- @original_method = @subject.method(@method_name)
80
- @subject.methods.should include(@method_name.to_s)
81
- @double_injection = DoubleInjection.new(@subject, @method_name)
55
+ subject.should respond_to(method_name)
56
+ @original_method = subject.method(method_name)
57
+ subject.methods.should include(method_name.to_s)
58
+ @double_injection = RR::Space.double_injection(subject, method_name)
82
59
  end
83
60
 
84
61
  it "overrides the original method with the double_injection's dispatching methods" do
85
- @subject.respond_to?(:"__rr__#{@method_name}").should == false
86
- @double_injection.bind
87
- @subject.respond_to?(:"__rr__#{@method_name}").should == true
88
-
89
- override_called = false
90
- method_name = @method_name
91
- (class << @subject; self; end).class_eval do
92
- define_method :"__rr__#{method_name}" do
93
- override_called = true
94
- end
95
- end
96
-
97
- override_called.should == false
98
- @subject == 1
99
- override_called.should == true
62
+ subject.method(method_name).should_not == original_method
100
63
  end
101
64
 
102
- it "stores original method in __rr__original_method_name" do
103
- @double_injection.bind
104
- @subject.respond_to?(:"__rr__original_#{@method_name}").should == true
105
- @subject.method(:"__rr__original_#{@method_name}").should == @original_method
65
+ it "stores original method in __rr__original_method_alias_name" do
66
+ subject.respond_to?(:"__rr__original_#{method_name}").should == true
67
+ subject.method(:"__rr__original_#{method_name}").should == original_method
106
68
  end
107
69
  end
108
70
  end
@@ -1,55 +1,58 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
2
2
 
3
3
  module RR
4
- describe DoubleInjection, "#object_has_original_method?" do
5
- before do
6
- @subject = Object.new
7
- @method_name = :to_s
8
- @double_injection = DoubleInjection.new(@subject, @method_name)
9
- class << @double_injection
10
- public :original_method_name
4
+ describe DoubleInjection do
5
+ describe "#object_has_original_method?" do
6
+ attr_reader :subject, :method_name, :double_injection
7
+ before do
8
+ @subject = Object.new
9
+ @method_name = :to_s
10
+ @double_injection = DoubleInjection.new(subject, method_name, (class << subject; self; end))
11
+ class << double_injection
12
+ public :original_method_alias_name
13
+ end
11
14
  end
12
- end
13
-
14
- it "returns true when method is still in object" do
15
- @double_injection.bind
16
- @double_injection.object_has_original_method?.should be_true
17
- end
18
15
 
19
- it "returns true when respond_to is true and methods include method" do
20
- @double_injection.bind
21
- def @subject.methods
22
- [:__rr_original_to_s]
23
- end
24
- def @subject.respond_to?(value)
25
- true
16
+ it "returns true when method is still in object" do
17
+ double_injection.bind
18
+ double_injection.object_has_original_method?.should be_true
26
19
  end
27
20
 
28
- @double_injection.object_has_original_method?.should be_true
29
- end
21
+ it "returns true when respond_to is true and methods include method" do
22
+ double_injection.bind
23
+ def subject.methods
24
+ [:__rr_original_to_s]
25
+ end
26
+ def subject.respond_to?(value)
27
+ true
28
+ end
30
29
 
31
- it "returns true when respond_to is true and methods do not include method" do
32
- @double_injection.bind
33
- def @subject.methods
34
- []
35
- end
36
- def @subject.respond_to?(value)
37
- true
30
+ double_injection.object_has_original_method?.should be_true
38
31
  end
39
32
 
40
- @double_injection.object_has_original_method?.should be_true
41
- end
33
+ it "returns true when respond_to is true and methods do not include method" do
34
+ double_injection.bind
35
+ def subject.methods
36
+ []
37
+ end
38
+ def subject.respond_to?(value)
39
+ true
40
+ end
42
41
 
43
- it "returns false when respond_to is false and methods do not include method" do
44
- @double_injection.bind
45
- def @subject.methods
46
- []
47
- end
48
- def @subject.respond_to?(value)
49
- false
42
+ double_injection.object_has_original_method?.should be_true
50
43
  end
51
44
 
52
- @double_injection.object_has_original_method?.should be_false
45
+ it "returns false when respond_to is false and methods do not include method" do
46
+ double_injection.bind
47
+ def subject.methods
48
+ []
49
+ end
50
+ def subject.respond_to?(value)
51
+ false
52
+ end
53
+
54
+ double_injection.object_has_original_method?.should be_false
55
+ end
53
56
  end
54
57
  end
55
58
  end
@@ -2,84 +2,66 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
2
2
 
3
3
  module RR
4
4
  describe DoubleInjection do
5
- macro("cleans up by removing the __rr__method") do
6
- it "cleans up by removing the __rr__method" do
7
- @double_injection.bind
8
- @subject.methods.should include("__rr__foobar")
9
-
10
- @double_injection.reset
11
- @subject.methods.should_not include("__rr__foobar")
12
- end
13
- end
14
-
15
5
  describe "#reset" do
6
+ attr_reader :subject, :method_name, :double_injection
16
7
  context "when method does not exist" do
17
- send("cleans up by removing the __rr__method")
18
-
19
8
  before do
20
9
  @subject = Object.new
21
10
  @method_name = :foobar
22
- @subject.methods.should_not include(@method_name.to_s)
23
- @double_injection = DoubleInjection.new(@subject, @method_name)
11
+ subject.methods.should_not include(method_name.to_s)
12
+ @double_injection = DoubleInjection.new(subject, method_name, (class << subject; self; end))
24
13
  end
25
14
 
26
15
  it "removes the method" do
27
- @double_injection.bind
28
- @subject.methods.should include(@method_name.to_s)
16
+ double_injection.bind
17
+ subject.methods.should include(method_name.to_s)
29
18
 
30
- @double_injection.reset
31
- @subject.methods.should_not include(@method_name.to_s)
32
- lambda {@subject.foobar}.should raise_error(NoMethodError)
19
+ double_injection.reset
20
+ subject.methods.should_not include(method_name.to_s)
21
+ lambda {subject.foobar}.should raise_error(NoMethodError)
33
22
  end
34
23
  end
35
24
 
36
25
  context "when method exists" do
37
- send("cleans up by removing the __rr__method")
38
-
39
26
  before do
40
27
  @subject = Object.new
41
28
  @method_name = :foobar
42
- def @subject.foobar
29
+ def subject.foobar
43
30
  :original_foobar
44
31
  end
45
- @subject.methods.should include(@method_name.to_s)
46
- @original_method = @subject.method(@method_name)
47
- @double_injection = DoubleInjection.new(@subject, @method_name)
48
-
49
- @double_injection.bind
50
- @subject.methods.should include(@method_name.to_s)
32
+ subject.methods.should include(method_name.to_s)
33
+ @original_method = subject.method(method_name)
34
+ @double_injection = RR::Space.double_injection(subject, method_name)
35
+ subject.methods.should include(method_name.to_s)
51
36
  end
52
37
 
53
38
  it "rebind original method" do
54
- @double_injection.reset
55
- @subject.methods.should include(@method_name.to_s)
56
- @subject.foobar.should == :original_foobar
39
+ double_injection.reset
40
+ subject.methods.should include(method_name.to_s)
41
+ subject.foobar.should == :original_foobar
57
42
  end
58
43
  end
59
44
 
60
45
  context "when method with block exists" do
61
- send("cleans up by removing the __rr__method")
62
-
63
46
  before do
64
47
  @subject = Object.new
65
48
  @method_name = :foobar
66
- def @subject.foobar
49
+ def subject.foobar
67
50
  yield(:original_argument)
68
51
  end
69
- @subject.methods.should include(@method_name.to_s)
70
- @original_method = @subject.method(@method_name)
71
- @double_injection = DoubleInjection.new(@subject, @method_name)
52
+ subject.methods.should include(method_name.to_s)
53
+ @original_method = subject.method(method_name)
54
+ @double_injection = RR::Space.double_injection(subject, method_name)
72
55
 
73
- @double_injection.bind
74
- @subject.methods.should include(@method_name.to_s)
56
+ subject.methods.should include(method_name.to_s)
75
57
  end
76
58
 
77
59
  it "rebinds original method with block" do
78
- @double_injection.reset
79
- @subject.methods.should include(@method_name.to_s)
60
+ double_injection.reset
61
+ subject.methods.should include(method_name.to_s)
80
62
 
81
63
  original_argument = nil
82
- @subject.foobar do |arg|
64
+ subject.foobar do |arg|
83
65
  original_argument = arg
84
66
  end
85
67
  original_argument.should == :original_argument
@@ -18,7 +18,7 @@ module RR
18
18
  @subject = Object.new
19
19
  @method_name = :foobar
20
20
  subject.methods.should_not include(method_name.to_s)
21
- @double_injection = DoubleInjection.new(subject, method_name)
21
+ @double_injection = DoubleInjection.new(subject, method_name, (class << subject; self; end))
22
22
  end
23
23
  end
24
24
 
@@ -29,7 +29,7 @@ module RR
29
29
  @subject = Object.new
30
30
  @method_name = 'foobar'
31
31
  subject.methods.should_not include(method_name)
32
- @double_injection = DoubleInjection.new(subject, method_name)
32
+ @double_injection = DoubleInjection.new(subject, method_name, (class << subject; self; end))
33
33
  end
34
34
  end
35
35
 
@@ -42,7 +42,7 @@ module RR
42
42
 
43
43
  context "and invoking the method for the first time does not add the method" do
44
44
  before do
45
- @double_injection = DoubleInjection.new(subject, method_name)
45
+ @double_injection = DoubleInjection.new(subject, method_name, (class << subject; self; end))
46
46
  end
47
47
  send("sets up object and method_name")
48
48
 
@@ -50,29 +50,6 @@ module RR
50
50
  double_injection.object_has_original_method?.should be_false
51
51
  end
52
52
  end
53
-
54
-
55
- context "and invoking the method for the first time adds the method" do
56
- before do
57
- class << subject
58
- def respond_to?(method_name)
59
- true
60
- end
61
-
62
- def method_missing(method_name, *args, &block)
63
- (class << self; self; end).class_eval do
64
- define_method(method_name) {}
65
- end
66
- end
67
- end
68
- @double_injection = DoubleInjection.new(subject, method_name)
69
- end
70
- send("sets up object and method_name")
71
-
72
- example "object has original method" do
73
- double_injection.object_has_original_method?.should be_true
74
- end
75
- end
76
53
  end
77
54
 
78
55
  context "when method exists on object" do
@@ -82,7 +59,7 @@ module RR
82
59
  @subject = Object.new
83
60
  @method_name = :to_s
84
61
  subject.methods.should include(method_name.to_s)
85
- @double_injection = DoubleInjection.new(subject, method_name)
62
+ @double_injection = DoubleInjection.new(subject, method_name, (class << subject; self; end))
86
63
  end
87
64
 
88
65
  it "has a original_method" do
@@ -96,7 +73,7 @@ module RR
96
73
  before do
97
74
  @subject = Object.new
98
75
  @method_name = '=='
99
- @double_injection = DoubleInjection.new(subject, method_name)
76
+ @double_injection = DoubleInjection.new(subject, method_name, (class << subject; self; end))
100
77
  end
101
78
  end
102
79
  end
@@ -74,8 +74,9 @@ module RR
74
74
  end
75
75
 
76
76
  it "overrides the method when passing a block" do
77
- @double_injection = space.double_injection(subject, method_name)
78
- subject.methods.should include("__rr__#{method_name}")
77
+ original_method = subject.method(:foobar)
78
+ double_injection = space.double_injection(subject, method_name)
79
+ subject.method(:foobar).should_not == original_method
79
80
  end
80
81
  end
81
82
 
@@ -166,16 +167,20 @@ module RR
166
167
  describe "#reset_double" do
167
168
  before do
168
169
  @method_name = :foobar
170
+ def subject.foobar
171
+ end
169
172
  end
170
173
 
171
- it "resets the double_injections" do
174
+ it "resets the double_injections and restores the original method" do
175
+ original_method = subject.method(method_name)
176
+
172
177
  @double_injection = space.double_injection(subject, method_name)
173
178
  space.double_injections[subject][method_name].should === double_injection
174
- subject.methods.should include("__rr__#{method_name}")
179
+ subject.method(method_name).should_not == original_method
175
180
 
176
181
  space.reset_double(subject, method_name)
177
182
  space.double_injections[subject][method_name].should be_nil
178
- subject.methods.should_not include("__rr__#{method_name}")
183
+ subject.method(method_name).should == original_method
179
184
  end
180
185
 
181
186
  context "when it has no double_injections" do
@@ -421,12 +426,13 @@ module RR
421
426
  describe "#verify_double" do
422
427
  before do
423
428
  @method_name = :foobar
429
+ def subject.foobar
430
+ end
424
431
  end
425
432
 
426
433
  it "verifies and deletes the double_injection" do
427
434
  @double_injection = space.double_injection(subject, method_name)
428
435
  space.double_injections[subject][method_name].should === double_injection
429
- subject.methods.should include("__rr__#{method_name}")
430
436
 
431
437
  verify_call_count = 0
432
438
  (class << double_injection; self; end).class_eval do
@@ -438,14 +444,16 @@ module RR
438
444
  verify_call_count.should == 1
439
445
 
440
446
  space.double_injections[subject][method_name].should be_nil
441
- subject.methods.should_not include("__rr__#{method_name}")
442
447
  end
443
448
 
444
449
  context "when verifying the double_injection raises an error" do
445
- it "deletes the double_injection" do
450
+ it "deletes the double_injection and restores the original method" do
451
+ original_method = subject.method(method_name)
452
+
446
453
  @double_injection = space.double_injection(subject, method_name)
454
+ subject.method(method_name).should_not == original_method
455
+
447
456
  space.double_injections[subject][method_name].should === double_injection
448
- subject.methods.should include("__rr__#{method_name}")
449
457
 
450
458
  verify_called = true
451
459
  (class << double_injection; self; end).class_eval do
@@ -458,7 +466,7 @@ module RR
458
466
  verify_called.should be_true
459
467
 
460
468
  space.double_injections[subject][method_name].should be_nil
461
- subject.methods.should_not include("__rr__#{method_name}")
469
+ subject.method(method_name).should == original_method
462
470
  end
463
471
  end
464
472
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Takita
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-25 00:00:00 -07:00
12
+ date: 2009-06-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15