spec/rspec/substitute_for_spec.rb in surrogate-0.6.5 vs spec/rspec/substitute_for_spec.rb in surrogate-0.7.0
- old
+ new
@@ -186,14 +186,18 @@
klass = Class.new { def instance_meth(a) end }
surrogate = Surrogate.endow(Class.new).define(:instance_meth) { |b| }
klass.should substitute_for surrogate, names: false, types: true
end
- it 'disregards when surrogate has no body for an api method' do
- klass = Class.new { def instance_meth(a) end }
+ it 'treats a bastard method as a no arity method' do
surrogate = Surrogate.endow(Class.new).define :instance_meth
+
+ klass = Class.new { def instance_meth() end }
klass.should substitute_for surrogate, types: true
+
+ klass = Class.new { def instance_meth(a) end }
+ klass.should_not substitute_for surrogate, types: true
end
it 'disregards when real object has natively implemented methods that cannot be reflected on' do
Array.method(:[]).parameters.should == [[:rest]] # make sure Array signatures aren't changing across versions or something
Array.instance_method(:insert).parameters.should == [[:rest]]
@@ -284,18 +288,26 @@
klass = Class.new { def self.class_meth(a=1) end }
surrogate = Surrogate.endow(Class.new) { define(:class_meth) {|a|} }
klass.should substitute_for surrogate, types: false, names: true
end
- it 'disregards when surrogate has no body for an api method' do
+ it 'treats bastard methods as no arity methods' do
# instance
- klass = Class.new { def instance_meth(a) end }
surrogate = Surrogate.endow(Class.new).define(:instance_meth)
+
+ klass = Class.new { def instance_meth(a) end }
+ klass.should_not substitute_for surrogate, names: true
+
+ klass = Class.new { def instance_meth() end }
klass.should substitute_for surrogate, names: true
# class
- klass = Class.new { def self.class_meth(a) end }
surrogate = Surrogate.endow(Class.new) { define :class_meth }
+
+ klass = Class.new { def self.class_meth(a) end }
+ klass.should_not substitute_for surrogate, names: true
+
+ klass = Class.new { def self.class_meth() end }
klass.should substitute_for surrogate, names: true
end
it 'disregards when real object has natively implemented methods that cannot be reflected on' do
Array.method(:[]).parameters.should == [[:rest]] # make sure Array signatures aren't changing across versions or something