reflexive 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,87 @@
1
+ require "ostruct"
2
+
3
+ module IntegrationSpecFixture
4
+ module TestBaseModule
5
+ end
6
+
7
+ module TestModule
8
+ include TestBaseModule
9
+ def module_meth
10
+ end
11
+
12
+ def self.module_class_meth
13
+ end
14
+ end
15
+
16
+ class TestBaseClass
17
+ def inherited_meth
18
+ end
19
+
20
+ def self.inherited_class_meth
21
+ end
22
+
23
+ def self.another_inherited_class_meth
24
+ end
25
+ end
26
+
27
+ class TestClass < TestBaseClass
28
+ include TestModule
29
+
30
+ another_inherited_class_meth
31
+
32
+ def self.class_meth
33
+ inherited_class_meth
34
+ end
35
+
36
+ def public_meth
37
+ inherited_meth
38
+ end
39
+
40
+ class_eval do
41
+ end
42
+
43
+ protected
44
+ def protected_meth
45
+ local_var = 42
46
+ another_local_var = 42 + local_var
47
+ not_defined_meth
48
+ end
49
+
50
+ private
51
+ def private_meth
52
+ end
53
+
54
+ class NestedClass
55
+ def meth
56
+ end
57
+ end
58
+ end
59
+
60
+ module HeuristicLookupBaseModule
61
+ end
62
+
63
+ class HeuristicLookupIncludingClass1
64
+ include HeuristicLookupBaseModule
65
+ def meth
66
+ end
67
+ end
68
+
69
+ class HeuristicLookupIncludingClass2
70
+ include HeuristicLookupBaseModule
71
+ def meth
72
+ end
73
+ end
74
+
75
+ class HeuristicLookupBaseClass
76
+ end
77
+
78
+ class HeuristicLookupInheritingClass1 < HeuristicLookupBaseClass
79
+ def meth
80
+ end
81
+ end
82
+
83
+ class HeuristicLookupInheritingClass2 < HeuristicLookupBaseClass
84
+ def meth
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,348 @@
1
+ require "reflexive/method_lookup"
2
+
3
+ class TestBaseClass
4
+ def self.inherited_class_meth
5
+ end
6
+
7
+ def inherited_instance_meth
8
+ end
9
+ end
10
+
11
+ class TestClass < TestBaseClass
12
+ def initialize
13
+ end
14
+
15
+ def self.class_meth
16
+ end
17
+
18
+ def instance_meth
19
+ end
20
+ end
21
+
22
+ module TestBaseModule
23
+ def inherited_module_meth
24
+ end
25
+ end
26
+
27
+ module TestModule
28
+ include TestBaseModule
29
+
30
+ def self.class_module_meth
31
+ end
32
+
33
+ def instance_module_meth
34
+ end
35
+ end
36
+
37
+ class TestCoreMethodsCallingClass
38
+ # # Module is class
39
+ # # Module class
40
+ # Module.new
41
+ # Module.nesting
42
+ # Module.constants
43
+ #
44
+ # # Module instance
45
+ # class_eval do
46
+ #
47
+ # end
48
+ # # many more...
49
+ #
50
+ # # Class class
51
+ # Class.inherited
52
+ # Class.new
53
+ #
54
+ # # Class instance
55
+ # allocate
56
+ # new
57
+ # superclass
58
+ #
59
+ # # Object instance
60
+ # Object.new # single
61
+ #
62
+ # # Object instance
63
+ # clone
64
+ # dup
65
+ # freeze
66
+ #
67
+ # # Kernel is module
68
+ # # Kernel instance
69
+ # Array
70
+ # caller
71
+ # # many more...
72
+ end
73
+
74
+ describe Reflexive::MethodLookup do
75
+ def ml(*args)
76
+ Reflexive::MethodLookup.new(*args)
77
+ end
78
+
79
+ def lookup_definitions(klass, level, name)
80
+ Reflexive::MethodLookup.new(klass: klass, level: level, name: name).definitions
81
+ end
82
+
83
+ def lookup_documentations(klass, level, name)
84
+ Reflexive::MethodLookup.new(klass: klass, level: level, name: name).documentations
85
+ end
86
+
87
+ it "requires :klass, :level, :name as constructor arguments" do
88
+ proc { ml }.should raise_error(ArgumentError)
89
+ proc { ml(klass: TestClass) }.should raise_error(ArgumentError)
90
+ proc { ml(level: :instance) }.should raise_error(ArgumentError)
91
+ proc { ml(name: :meth) }.should raise_error(ArgumentError)
92
+ proc { ml(klass: TestClass, level: :class) }.should raise_error(ArgumentError)
93
+ proc { ml(klass: TestClass, level: :class, name: "meth") }.should_not raise_error
94
+ end
95
+
96
+ it "finds defined inherited instance methods for class" do
97
+ lookup_definitions(TestClass, :instance, :inherited_instance_meth).should ==
98
+ [[TestClass, :instance, :inherited_instance_meth]]
99
+ end
100
+
101
+ it "handles level and module names passed as strings normalizing them to symbols" do
102
+ lookup_definitions(TestClass, "instance", "inherited_instance_meth").should ==
103
+ [[TestClass, :instance, :inherited_instance_meth]]
104
+ end
105
+
106
+ it "finds defined inherited instance methods for module" do
107
+ lookup_definitions(TestModule, :instance, :inherited_module_meth).should ==
108
+ [[TestModule, :instance, :inherited_module_meth]]
109
+ end
110
+
111
+ it "finds defined owned instance methods for class" do
112
+ lookup_definitions(TestClass, :instance, :instance_meth).should ==
113
+ [[TestClass, :instance, :instance_meth]]
114
+ end
115
+
116
+ it "finds defined owned instance methods for module" do
117
+ lookup_definitions(TestModule, :instance, :instance_module_meth).should ==
118
+ [[TestModule, :instance, :instance_module_meth]]
119
+ end
120
+
121
+ it "finds defined inherited class methods" do
122
+ lookup_definitions(TestClass, :class, :inherited_class_meth).should ==
123
+ [[TestClass, :class, :inherited_class_meth]]
124
+ end
125
+
126
+ it "finds defined owned class methods for class" do
127
+ lookup_definitions(TestClass, :class, :class_meth).should ==
128
+ [[TestClass, :class, :class_meth]]
129
+ end
130
+
131
+ it "finds defined owned class methods for module" do
132
+ lookup_definitions(TestModule, :class, :class_module_meth).should ==
133
+ [[TestModule, :class, :class_module_meth]]
134
+ end
135
+
136
+ it "redirects class new method to instance initialize for classes" do
137
+ lookup_definitions(TestClass, :class, :new).should ==
138
+ [[TestClass, :instance, :initialize]]
139
+ end
140
+
141
+ describe "lookup of core native methods" do
142
+ it "for Kernel always redirects to instance methods" do
143
+ lookup_documentations(TestClass, :class, :require).should ==
144
+ [[Kernel, :instance, :require]]
145
+
146
+ lookup_documentations(TestClass, :instance, :require).should ==
147
+ [[Kernel, :instance, :require]]
148
+ end
149
+
150
+ it "for Module redirects to instance methods mostly" do
151
+ lookup_documentations(TestClass, :class, :class_eval).should ==
152
+ [[Module, :instance, :class_eval]]
153
+
154
+ lookup_documentations(Module, :class, :nesting).should ==
155
+ [[Module, :class, :nesting]]
156
+
157
+ # lookup_documentations(TestClass, :instance, :require).should ==
158
+ # [[Kernel, :instance, :require]]
159
+ end
160
+
161
+ it "for Class redirects to instance methods mostly" do
162
+ lookup_documentations(TestClass, :class, :superclass).should ==
163
+ [[Class, :instance, :superclass]]
164
+
165
+
166
+ # lookup_documentations(TestClass, :instance, :require).should ==
167
+ # [[Kernel, :instance, :require]]
168
+ end
169
+
170
+ class InheritedFromDir < Dir
171
+ end
172
+
173
+ it "doesn't handle normal library classes in a specific way" do
174
+ lookup_documentations(File, :class, :expand_path).should ==
175
+ [[File, :class, :expand_path]]
176
+ lookup_documentations(Dir, :instance, :path).should ==
177
+ [[Dir, :instance, :path]]
178
+ lookup_documentations(InheritedFromDir, :instance, :path).should ==
179
+ [[Dir, :instance, :path]]
180
+ lookup_documentations(InheritedFromDir, :class, :entries).should ==
181
+ [[Dir, :class, :entries]]
182
+ end
183
+ end
184
+
185
+ describe "heuristic lookup" do
186
+
187
+ describe "for just included module" do
188
+ module JustIncludedModule
189
+ def module_instance_meth
190
+ instance_meth
191
+ end
192
+ end
193
+
194
+ class IncludesJustIncludedModule
195
+ include JustIncludedModule
196
+
197
+ def instance_meth
198
+ 42
199
+ end
200
+ end
201
+
202
+ class IncludesJustIncludedModuleAnother
203
+ include JustIncludedModule
204
+
205
+ def instance_meth
206
+ 43
207
+ end
208
+ end
209
+
210
+ class IncludesJustIncludedModuleYetAnother
211
+ include JustIncludedModule
212
+ end
213
+
214
+ it "should setup sane fixture" do
215
+ IncludesJustIncludedModule.new.module_instance_meth.should == 42
216
+ IncludesJustIncludedModuleAnother.new.module_instance_meth.should == 43
217
+ end
218
+
219
+ it "finds instance_meth" do
220
+ lookup_definitions(JustIncludedModule, :instance, :instance_meth).should =~
221
+ [[IncludesJustIncludedModule, :instance, :instance_meth],
222
+ [IncludesJustIncludedModuleAnother, :instance, :instance_meth]]
223
+ end
224
+ end
225
+
226
+ describe "for module included in singleton class" do
227
+ module JustIncludedInSingletonModule
228
+ def module_class_meth
229
+ class_meth
230
+ end
231
+ end
232
+
233
+ class IncludesJustIncludedInSingletonModule
234
+ extend JustIncludedInSingletonModule
235
+
236
+ def self.class_meth
237
+ 42
238
+ end
239
+ end
240
+
241
+ it "should setup sane fixture" do
242
+ IncludesJustIncludedInSingletonModule.module_class_meth.should == 42
243
+ end
244
+
245
+ it "finds class_meth" do
246
+ lookup_definitions(JustIncludedInSingletonModule, :instance, :class_meth).should ==
247
+ [[IncludesJustIncludedInSingletonModule, :class, :class_meth]]
248
+ end
249
+ end
250
+
251
+ describe "for module included in module included in class in turn" do
252
+ module IncludedInModuleIncludedInClass
253
+ def module_instance_meth
254
+ class_instance_meth
255
+ end
256
+ end
257
+
258
+ module IncludesIncludedInModuleIncludedInClass
259
+ include IncludedInModuleIncludedInClass
260
+ end
261
+
262
+ class IncludesIncludesIncludedInModuleIncludedInClass
263
+ include IncludesIncludedInModuleIncludedInClass
264
+ def class_instance_meth
265
+ 42
266
+ end
267
+ end
268
+
269
+ it "should setup sane fixture" do
270
+ IncludesIncludesIncludedInModuleIncludedInClass.new.module_instance_meth.should == 42
271
+ end
272
+
273
+ it "finds class_instance_meth" do
274
+ lookup_definitions(IncludedInModuleIncludedInClass, :instance, :class_instance_meth).should ==
275
+ [[IncludesIncludesIncludedInModuleIncludedInClass, :instance, :class_instance_meth]]
276
+ end
277
+ end
278
+
279
+ describe "for base class instance methods" do
280
+ class HeuristicLookupBaseClassInstanceMethods
281
+ def base_class_instance_meth
282
+ inherited_class_instance_meth
283
+ end
284
+ end
285
+
286
+ class HeuristicLookupInheritedClassInstanceMethods < HeuristicLookupBaseClassInstanceMethods
287
+ def inherited_class_instance_meth
288
+ 42
289
+ end
290
+ end
291
+
292
+ class HeuristicLookupInheritedClassInstanceMethodsAnother < HeuristicLookupBaseClassInstanceMethods
293
+ def inherited_class_instance_meth
294
+ 43
295
+ end
296
+ end
297
+
298
+ it "should setup sane fixture" do
299
+ HeuristicLookupInheritedClassInstanceMethods.new.base_class_instance_meth.should == 42
300
+ end
301
+
302
+ it "finds inherited_class_instance_meth" do
303
+ lookup_definitions(HeuristicLookupBaseClassInstanceMethods, :instance, :inherited_class_instance_meth).should =~
304
+ [[HeuristicLookupInheritedClassInstanceMethods, :instance, :inherited_class_instance_meth],
305
+ [HeuristicLookupInheritedClassInstanceMethodsAnother, :instance, :inherited_class_instance_meth]]
306
+ end
307
+ end
308
+
309
+ describe "for base class class methods" do
310
+ class HeuristicLookupBaseClassClassMethods
311
+ def self.base_class_class_meth
312
+ inherited_class_class_meth
313
+ end
314
+ end
315
+
316
+ class HeuristicLookupInheritedClassClassMethods < HeuristicLookupBaseClassClassMethods
317
+ def self.inherited_class_class_meth
318
+ 42
319
+ end
320
+ end
321
+
322
+ it "should setup sane fixture" do
323
+ HeuristicLookupInheritedClassClassMethods.base_class_class_meth.should == 42
324
+ end
325
+
326
+ it "finds inherited_class_class_meth" do
327
+ lookup_definitions(HeuristicLookupBaseClassClassMethods, :class, :inherited_class_class_meth).should ==
328
+ [[HeuristicLookupInheritedClassClassMethods, :class, :inherited_class_class_meth]]
329
+ end
330
+ end
331
+
332
+ describe "last resort lookup" do
333
+ module LastResortTestModule
334
+ end
335
+
336
+ class LastResortTestClass
337
+ def some_really_uniq_instance_method
338
+ end
339
+ end
340
+
341
+ it "finds some_really_uniq_instance_method" do
342
+ lookup_definitions(LastResortTestModule, :instance, :some_really_uniq_instance_method).should ==
343
+ [[LastResortTestClass, :instance, :some_really_uniq_instance_method]]
344
+ end
345
+ end
346
+ end
347
+ end
348
+
data/spec/methods_spec.rb CHANGED
@@ -14,26 +14,243 @@ Rspec::Matchers.define :generate_methods do |expected|
14
14
  end
15
15
  end
16
16
 
17
+ describe "Ruby reflection capabilities" do
18
+ describe "for Modules" do
19
+ describe "#singleton_class" do
20
+ specify ".public_instance_methods(false) returns empty list for empty module" do
21
+ Module.new.singleton_class.
22
+ reflexive_public_instance_methods(false).should == []
23
+ end
24
+
25
+ specify ".protected_instance_methods(false) returns empty list for empty module" do
26
+ Module.new.singleton_class.
27
+ reflexive_protected_instance_methods(false).should == []
28
+ end
29
+
30
+ specify ".private_instance_methods(false) returns empty list for empty module" do
31
+ Module.new.singleton_class.
32
+ reflexive_private_instance_methods(false).should == []
33
+ end
34
+
35
+ specify ".public_instance_methods(false) returns public methods" do
36
+ Module.new { def self.m; end }.singleton_class.
37
+ reflexive_public_instance_methods(false).should == [:m]
38
+ end
39
+
40
+ specify ".protected_instance_methods(false) returns protected methods" do
41
+ Module.new { class << self; protected; def m; end end }.singleton_class.
42
+ reflexive_protected_instance_methods(false).should == [:m]
43
+ end
44
+
45
+ specify ".private_instance_methods(false) returns private methods" do
46
+ Module.new { class << self; private; def m; end end }.singleton_class.
47
+ reflexive_private_instance_methods(false).should == [:m]
48
+ end
49
+ end
50
+
51
+ specify ".public_instance_methods(false) returns empty list for empty module" do
52
+ Module.new.
53
+ reflexive_public_instance_methods(false).should == []
54
+ end
55
+
56
+ specify ".protected_instance_methods(false) returns empty list for empty module" do
57
+ Module.new.
58
+ reflexive_protected_instance_methods(false).should == []
59
+ end
60
+
61
+ specify ".private_instance_methods(false) returns empty list for empty module" do
62
+ Module.new.
63
+ reflexive_private_instance_methods(false).should == []
64
+ end
65
+
66
+ specify ".public_instance_methods(false) returns public methods" do
67
+ Module.new { def m; end }.
68
+ reflexive_public_instance_methods(false).should == [:m]
69
+ end
70
+
71
+ specify ".protected_instance_methods(false) returns protected methods" do
72
+ Module.new { protected; def m; end }.
73
+ reflexive_protected_instance_methods(false).should == [:m]
74
+ end
75
+
76
+ specify ".private_instance_methods(false) returns private methods" do
77
+ Module.new { private; def m; end }.
78
+ reflexive_private_instance_methods(false).should == [:m]
79
+ end
80
+ end
81
+
82
+ describe "for Classes" do
83
+ class ::RubyReflectionCapabilitiesEmptyClass
84
+ end
85
+
86
+ class ::RubyReflectionCapabilitiesSingletonMethodsClass
87
+ class << self
88
+ def publ
89
+ end
90
+ protected
91
+ def prot
92
+ end
93
+ private
94
+ def priv
95
+ end
96
+ end
97
+ end
98
+
99
+ class ::RubyReflectionCapabilitiesInstanceMethodsClass
100
+ def publ
101
+ end
102
+ protected
103
+ def prot
104
+ end
105
+ private
106
+ def priv
107
+ end
108
+ end
109
+
110
+ describe "#singleton_class" do
111
+ specify ".public_instance_methods(false) returns empty list for empty class" do
112
+ RubyReflectionCapabilitiesEmptyClass.singleton_class.
113
+ reflexive_public_instance_methods(false).should == []
114
+ end
115
+
116
+ specify ".protected_instance_methods(false) returns empty list for empty class" do
117
+ RubyReflectionCapabilitiesEmptyClass.singleton_class.
118
+ reflexive_protected_instance_methods(false).should == []
119
+ end
120
+
121
+ specify ".private_instance_methods(false) returns empty list for empty class" do
122
+ RubyReflectionCapabilitiesEmptyClass.singleton_class.
123
+ reflexive_private_instance_methods(false).should == []
124
+ end
125
+
126
+ specify ".public_instance_methods(false) returns public methods" do
127
+ RubyReflectionCapabilitiesSingletonMethodsClass.singleton_class.
128
+ reflexive_public_instance_methods(false).should == [:publ]
129
+ end
130
+
131
+ specify ".protected_instance_methods(false) returns protected methods" do
132
+ RubyReflectionCapabilitiesSingletonMethodsClass.singleton_class.
133
+ reflexive_protected_instance_methods(false).should == [:prot]
134
+ end
135
+
136
+ specify ".private_instance_methods(false) returns private methods" do
137
+ RubyReflectionCapabilitiesSingletonMethodsClass.singleton_class.
138
+ reflexive_private_instance_methods(false).should == [:priv]
139
+ end
140
+ end
141
+
142
+ describe "#" do
143
+ specify ".public_instance_methods(false) returns empty list for empty class" do
144
+ RubyReflectionCapabilitiesEmptyClass.
145
+ reflexive_public_instance_methods(false).should == []
146
+ end
147
+
148
+ specify ".protected_instance_methods(false) returns empty list for empty class" do
149
+ RubyReflectionCapabilitiesEmptyClass.
150
+ reflexive_protected_instance_methods(false).should == []
151
+ end
152
+
153
+ specify ".private_instance_methods(false) returns empty list for empty class" do
154
+ RubyReflectionCapabilitiesEmptyClass.
155
+ reflexive_private_instance_methods(false).should == []
156
+ end
157
+
158
+ specify ".public_instance_methods(false) returns public methods" do
159
+ RubyReflectionCapabilitiesInstanceMethodsClass.
160
+ reflexive_public_instance_methods(false).should == [:publ]
161
+ end
162
+
163
+ specify ".protected_instance_methods(false) returns protected methods" do
164
+ RubyReflectionCapabilitiesInstanceMethodsClass.
165
+ reflexive_protected_instance_methods(false).should == [:prot]
166
+ end
167
+
168
+ specify ".private_instance_methods(false) returns private methods" do
169
+ RubyReflectionCapabilitiesInstanceMethodsClass.
170
+ reflexive_private_instance_methods(false).should == [:priv]
171
+ end
172
+ end
173
+ end
174
+ end
175
+
17
176
  describe Reflexive::Methods do
177
+ describe "#trite_singleton_ancestors" do
178
+ it "returns some common trite objects" do
179
+ Reflexive::Methods.new(nil).
180
+ send(:trite_singleton_ancestors).
181
+ should(include(Class, Module, Object, BasicObject, Kernel))
182
+ end
183
+ end
184
+
185
+ describe "#trite_ancestors" do
186
+ it "returns some common trite objects" do
187
+ Reflexive::Methods.new(nil).
188
+ send(:trite_ancestors).
189
+ should(include(Object, Kernel, BasicObject))
190
+ end
191
+ end
192
+
193
+ describe "#collect_instance_methods" do
194
+ class ::CollectInstanceMethodsC
195
+ def public_instance_meth
196
+ end
197
+ protected
198
+ def protected_instance_meth
199
+ end
200
+ private
201
+ def private_instance_meth
202
+ end
203
+ end
204
+
205
+ it "collects own (defined in class) instance methods for class" do
206
+ Reflexive::Methods.new(nil).
207
+ send(:collect_instance_methods, ::CollectInstanceMethodsC).
208
+ should == { :public => [ :public_instance_meth ],
209
+ :protected => [ :protected_instance_meth ],
210
+ :private => [ :private_instance_meth ] }
211
+ end
212
+
213
+ module ::CollectInstanceMethodsEmptyM
214
+ end
215
+
216
+ it "reports empty own instance methods for empty module" do
217
+ Reflexive::Methods.new(nil).
218
+ send(:collect_instance_methods, ::CollectInstanceMethodsEmptyM).
219
+ should == nil
220
+ end
221
+
222
+ it "reports empty own class methods for empty module" do
223
+ Reflexive::Methods.new(nil).
224
+ send(:collect_instance_methods, ::CollectInstanceMethodsEmptyM.singleton_class).
225
+ should == nil
226
+ end
227
+ end
228
+
18
229
  describe "ModuleInclusionC" do
19
- module ModuleInclusionA
230
+ module ::ModuleInclusionA
20
231
  def module_instance_from_A_WTF!
21
232
  end
22
233
  end
23
234
 
24
- module ModuleInclusionB
25
- include ModuleInclusionA
235
+ module ::ModuleInclusionB
236
+ include ::ModuleInclusionA
26
237
 
27
238
  def module_instance_from_B_WTF!
28
239
  end
29
240
  end
30
241
 
31
- module ModuleInclusionC
32
- include ModuleInclusionB
242
+ module ::ModuleInclusionC
243
+ include ::ModuleInclusionB
244
+ end
245
+
246
+ it "has ModuleInclusionA and ModuleInclusionB ancestors" do
247
+ ModuleInclusionC.ancestors.should =~ [ ModuleInclusionC,
248
+ ModuleInclusionA,
249
+ ModuleInclusionB ]
33
250
  end
34
251
 
35
252
  it "works" do
36
- ModuleInclusionC.should generate_methods(<<-METHODS_PP)
253
+ ::ModuleInclusionC.should generate_methods(<<-METHODS_PP)
37
254
  [{"[M] ModuleInclusionB"=>
38
255
  {:instance=>{:public=>[:module_instance_from_B_WTF!]}}},
39
256
  {"[M] ModuleInclusionA"=>
@@ -41,16 +258,17 @@ describe Reflexive::Methods do
41
258
  METHODS_PP
42
259
  end
43
260
  end
261
+
44
262
  describe "Inheritance" do
45
- class InheritanceA
263
+ class ::InheritanceA
46
264
  def self.singleton_inherited_from_A_WTF!
47
265
  end
48
266
  end
49
267
 
50
- class InheritanceB < InheritanceA
268
+ class ::InheritanceB < ::InheritanceA
51
269
  end
52
270
 
53
- class InheritanceC < InheritanceB
271
+ class ::InheritanceC < ::InheritanceB
54
272
  def test
55
273
  end
56
274
  end
@@ -64,19 +282,19 @@ describe Reflexive::Methods do
64
282
  end
65
283
 
66
284
  describe "SingletonAndInstance" do
67
- module M
285
+ module ::M
68
286
  def instance_from_moduleWTF!
69
287
  end
70
288
  end
71
289
 
72
- module SM
290
+ module ::SM
73
291
  def singleton_from_moduleWTF!
74
292
  end
75
293
  end
76
294
 
77
- class SingletonAndInstanceTest
78
- include M
79
- extend SM
295
+ class ::SingletonAndInstanceTest
296
+ include ::M
297
+ extend ::SM
80
298
 
81
299
  def self.singletonWTF!
82
300
  end
@@ -97,7 +315,7 @@ describe Reflexive::Methods do
97
315
  end
98
316
 
99
317
  describe "ExtendWithInstanceAndClass" do
100
- module ExtendWithInstanceAndClassM
318
+ module ::ExtendWithInstanceAndClassM
101
319
  def self.singleton_WTF!
102
320
  end
103
321
 
@@ -105,19 +323,19 @@ describe Reflexive::Methods do
105
323
  end
106
324
  end
107
325
 
108
- class ExtendWithInstanceAndClass
109
- extend ExtendWithInstanceAndClassM
326
+ class ::ExtendWithInstanceAndClass
327
+ extend ::ExtendWithInstanceAndClassM
110
328
  end
111
329
 
112
330
  it "works" do
113
- ExtendWithInstanceAndClass.should generate_methods(<<-METHODS_PP)
331
+ ::ExtendWithInstanceAndClass.should generate_methods(<<-METHODS_PP)
114
332
  [{"S[M] ExtendWithInstanceAndClassM"=>{:class=>{:public=>[:instance_WTF!]}}}]
115
333
  METHODS_PP
116
334
  end
117
335
  end
118
336
 
119
337
  describe "SingletonVisibility" do
120
- class SingletonVisibility
338
+ class ::SingletonVisibility
121
339
  def self.class_method
122
340
  end
123
341
 
@@ -138,7 +356,7 @@ describe Reflexive::Methods do
138
356
  end
139
357
 
140
358
  it "works" do
141
- SingletonVisibility.should generate_methods(<<-METHODS_PP)
359
+ ::SingletonVisibility.should generate_methods(<<-METHODS_PP)
142
360
  [{"[C] SingletonVisibility"=>
143
361
  {:class=>
144
362
  {:public=>[:class_method, :public_singleton_method],
@@ -149,28 +367,28 @@ describe Reflexive::Methods do
149
367
  end
150
368
 
151
369
  describe "SingletonOverrides" do
152
- class SingletonOverridesA
370
+ class ::SingletonOverridesA
153
371
  def self.overriden
154
372
  puts "A"
155
373
  # super
156
374
  end
157
375
  end
158
376
 
159
- module SingletonOverridesMB
377
+ module ::SingletonOverridesMB
160
378
  def overriden
161
379
  puts " MB"
162
380
  super
163
381
  end
164
382
  end
165
383
 
166
- class SingletonOverridesB < SingletonOverridesA
167
- extend SingletonOverridesMB
384
+ class ::SingletonOverridesB < ::SingletonOverridesA
385
+ extend ::SingletonOverridesMB
168
386
 
169
387
  def self.overriden
170
388
  end
171
389
  end
172
390
 
173
- module SingletonOverridesMC
391
+ module ::SingletonOverridesMC
174
392
  def overriden
175
393
  end
176
394
 
@@ -178,8 +396,8 @@ describe Reflexive::Methods do
178
396
  end
179
397
  end
180
398
 
181
- class SingletonOverridesC < SingletonOverridesB
182
- extend SingletonOverridesMC
399
+ class ::SingletonOverridesC < ::SingletonOverridesB
400
+ extend ::SingletonOverridesMC
183
401
 
184
402
  def self.class_WTF
185
403
  end
@@ -189,7 +407,7 @@ describe Reflexive::Methods do
189
407
  end
190
408
 
191
409
  it "works" do
192
- SingletonOverridesC.should generate_methods(<<-METHODS_PP)
410
+ ::SingletonOverridesC.should generate_methods(<<-METHODS_PP)
193
411
  [{"[C] SingletonOverridesC"=>{:class=>{:public=>[:class_WTF, :overriden]}}},
194
412
  {"S[M] SingletonOverridesMC"=>
195
413
  {:class=>{:public=>[:overriden, :singleton_WTF]}}},