spec/spec_helper.rb in cross-stub-0.1.3.1 vs spec/spec_helper.rb in cross-stub-0.1.4
- old
+ new
@@ -8,21 +8,25 @@
Bacon.summary_on_exit
shared 'has standard setup' do
before do
CrossStub.setup(:file => $cache_file)
+ @get_context = lambda do |klass_or_module|
+ klass_or_module.split(/::/).inject(Object) { |context, name| context.const_get(name) }
+ end
end
after do
CrossStub.clear
end
end
shared 'has current process setup' do
before do
@get_value = lambda do |klass_and_method_and_args|
klass, method, *args = klass_and_method_and_args.split('.')
- args.empty? ? Object.const_get(klass).send(method) :
- Object.const_get(klass).send(method, *args)
+ konst = klass.split(/::/).inject(Object) { |const_train, const| const_train.const_get(const) }
+ args.empty? ? konst.send(method) :
+ konst.send(method, *args)
end
end
end
shared 'has other process setup' do