evalhook 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 0.4.1 Fixed bug on hooking of node type super (lack of hooking for arguments)
2
+
1
3
  0.4.0 Removed evalmimic dependency
2
4
 
3
5
  Implemented hooking of super as methods calls
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/gempackagetask'
6
6
 
7
7
  spec = Gem::Specification.new do |s|
8
8
  s.name = 'evalhook'
9
- s.version = '0.4.0'
9
+ s.version = '0.4.1'
10
10
  s.author = 'Dario Seminara'
11
11
  s.email = 'robertodarioseminara@gmail.com'
12
12
  s.platform = Gem::Platform::RUBY
@@ -239,7 +239,7 @@ module EvalHook
239
239
  thirdcall = s(:call,secondcall,:set_class,s(:arglist, superclass_call_tree))
240
240
 
241
241
  # pass the args passed to super
242
- s(:call, thirdcall, :call, s(:arglist, *tree[1..-1]))
242
+ s(:call, thirdcall, :call, process(s(:arglist, *tree[1..-1])))
243
243
 
244
244
  end
245
245
 
@@ -179,4 +179,43 @@ describe EvalHook::HookHandler, "hook handler hooks" do
179
179
  ', binding).should be == 10
180
180
  end
181
181
 
182
+ class Y9 < X2
183
+
184
+ end
185
+ it "should intercept call on arguments of super" do
186
+ h = EvalHook::HookHandler.new
187
+
188
+ # reference to X for inheritance
189
+ h.should_receive(:handle_const).with("X2")
190
+
191
+ # reference to Y
192
+ h.should_receive(:handle_const).with("Y2")
193
+
194
+ # call to new
195
+ h.should_receive(:handle_method).with(Y2.class,Y2,:new)
196
+
197
+ # first Y#foo call
198
+ h.should_receive(:handle_method).with(Y2,anything(),:foo)
199
+
200
+ # call Y#bar
201
+ h.should_receive(:handle_method).with(Y2,anything(),:bar)
202
+
203
+ # super call
204
+ h.should_receive(:handle_method).with(X2,anything(),:foo)
205
+
206
+ h.evalhook('
207
+
208
+ class Y2 < X2
209
+ def bar
210
+ 9
211
+ end
212
+ def foo(a)
213
+ super(bar)
214
+ end
215
+ end
216
+ Y2.new.foo(9)
217
+
218
+ ', binding).should be == 10
219
+
220
+ end
182
221
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evalhook
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dario Seminara
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-28 00:00:00 -03:00
18
+ date: 2011-06-09 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency