rr 0.10.2 → 0.10.4

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.
@@ -1,58 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
2
-
3
- module RR
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
14
- end
15
-
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
19
- end
20
-
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
29
-
30
- double_injection.object_has_original_method?.should be_true
31
- end
32
-
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
41
-
42
- double_injection.object_has_original_method?.should be_true
43
- end
44
-
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
56
- end
57
- end
58
- end
@@ -1,72 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
2
-
3
- module RR
4
- describe DoubleInjection do
5
- describe "#reset" do
6
- attr_reader :subject, :method_name, :double_injection
7
- context "when method does not exist" do
8
- before do
9
- @subject = Object.new
10
- @method_name = :foobar
11
- subject.methods.should_not include(method_name.to_s)
12
- @double_injection = DoubleInjection.new(subject, method_name, (class << subject; self; end))
13
- end
14
-
15
- it "removes the method" do
16
- double_injection.bind
17
- subject.methods.should include(method_name.to_s)
18
-
19
- double_injection.reset
20
- subject.methods.should_not include(method_name.to_s)
21
- lambda {subject.foobar}.should raise_error(NoMethodError)
22
- end
23
- end
24
-
25
- context "when method exists" do
26
- before do
27
- @subject = Object.new
28
- @method_name = :foobar
29
- def subject.foobar
30
- :original_foobar
31
- end
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)
36
- end
37
-
38
- it "rebind original method" do
39
- double_injection.reset
40
- subject.methods.should include(method_name.to_s)
41
- subject.foobar.should == :original_foobar
42
- end
43
- end
44
-
45
- context "when method with block exists" do
46
- before do
47
- @subject = Object.new
48
- @method_name = :foobar
49
- def subject.foobar
50
- yield(:original_argument)
51
- end
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)
55
-
56
- subject.methods.should include(method_name.to_s)
57
- end
58
-
59
- it "rebinds original method with block" do
60
- double_injection.reset
61
- subject.methods.should include(method_name.to_s)
62
-
63
- original_argument = nil
64
- subject.foobar do |arg|
65
- original_argument = arg
66
- end
67
- original_argument.should == :original_argument
68
- end
69
- end
70
- end
71
- end
72
- end