hanging_methods 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hanging_methods (0.0.1)
4
+ hanging_methods (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module HangingMethods
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -30,7 +30,7 @@ module HangingMethods
30
30
  def add_hanging_method_name_and_args_invocation(hanging_method_name, method_name_and_args)
31
31
  hanging_method_invocations(hanging_method_name) << method_name_and_args
32
32
 
33
- ret = if after_invocation = self.class.hanging_method_options(hanging_method_name)[:after_invocation]
33
+ ret = if after_invocation = self.method(hanging_method_name).owner.hanging_method_options(hanging_method_name)[:after_invocation]
34
34
  send(after_invocation, method_name_and_args)
35
35
  end
36
36
  end
@@ -19,6 +19,9 @@ describe HangingMethods do
19
19
  method_name_and_args.size
20
20
  end
21
21
  end
22
+
23
+ class SubTestObject < TestObject
24
+ end
22
25
 
23
26
  describe "#hanging_method_invocations" do
24
27
  let(:client) { TestObject.new }
@@ -39,17 +42,29 @@ describe HangingMethods do
39
42
  end
40
43
 
41
44
  context "with after_invocation" do
42
- let!(:method_1_return) { client.add_more.a_method }
43
- let!(:method_2_return) { client.add_more.another_method('arg1', 'arg2') }
44
-
45
- it "should add invocation" do
46
- subject
47
- expect(client.add_more_invocations).to eq [[:a_method], [:another_method, 'arg1', 'arg2']]
45
+ context "with no subclassing" do
46
+ let!(:method_1_return) { client.add_more.a_method }
47
+ let!(:method_2_return) { client.add_more.another_method('arg1', 'arg2') }
48
+
49
+ it "should add invocation" do
50
+ subject
51
+ expect(client.add_more_invocations).to eq [[:a_method], [:another_method, 'arg1', 'arg2']]
52
+ end
53
+
54
+ it "should return the value of the after_invocation method" do
55
+ expect(method_1_return).to eq 1
56
+ expect(method_2_return).to eq 3
57
+ end
48
58
  end
49
59
 
50
- it "should return the value of the after_invocation method" do
51
- expect(method_1_return).to eq 1
52
- expect(method_2_return).to eq 3
60
+ context "with subclass object" do
61
+ let(:client) { SubTestObject.new }
62
+ let!(:method_1_return) { client.add_more.a_method }
63
+
64
+ it "should add invocation to the hanging method name owner class, not the sublcass" do
65
+ subject
66
+ expect(client.add_more_invocations).to eq [[:a_method]]
67
+ end
53
68
  end
54
69
  end
55
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanging_methods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: