spec/unit/api_comparer_spec.rb in surrogate-0.6.1 vs spec/unit/api_comparer_spec.rb in surrogate-0.6.2
- old
+ new
@@ -8,11 +8,11 @@
end
context 'when identifying types' do
it 'uses :req, :opt, :rest, and :block' do
surrogate = Surrogate.endow(Class.new).define(:to_s) { |a, b, c, d=1, e=2, *f, g, &h| }
- comparer = described_class.new(surrogate, Class.new)
+ comparer = described_class.new(Class.new, surrogate)
comparer.compare[:instance][:types][:to_s][:surrogate].should ==
[:req, :req, :req, :opt, :opt, :rest, :req, :block]
end
end
@@ -38,11 +38,11 @@
def instance_meth()end
def instance_meth_with_signature(a6, b6=1, *c6, d6, &e6)end
end
end
- let(:comparer) { described_class.new surrogate, Class.new }
+ let(:comparer) { described_class.new Class.new, surrogate }
it "knows the surrogate's instance level api methods" do
comparer.surrogate_methods[:instance][:api].should == Set[:api_instance_meth, :api_instance_meth_with_signature]
end
@@ -84,11 +84,11 @@
let :actual do
parent = Class.new { def self.inherited_class_meth()end; def inherited_instance_meth()end }
Class.new(parent) { def self.class_meth()end; def instance_meth()end }
end
- let(:comparer) { described_class.new surrogate, actual }
+ let(:comparer) { described_class.new actual, surrogate }
it "knows the object's inherited instance methods" do
set_assertion comparer.actual_methods[:instance][:inherited],
include: [:inherited_instance_meth],
exclude: [:inherited_class_meth, :class_meth, :instance_meth]
@@ -129,11 +129,11 @@
def instance_meth_on_both()end
def self.class_meth_on_both()end
end
end
- let(:comparer) { described_class.new surrogate, actual }
+ let(:comparer) { described_class.new actual, surrogate }
it 'tells me about instance methods on actual that are not on surrogate' do
comparer.compare[:instance][:not_on_surrogate].should == Set[:instance_not_on_surrogate, :inherited_instance_not_on_surrogate, :instance_meth_on_both]
end
@@ -173,11 +173,11 @@
def self.class_meth3(a3, b3=1, *c3, &d3)end
define(:instance_meth2) { |e2, f2=1, *c2, &d2| }
def instance_meth3(e3, f3=1, *c3, &d3)end
end
- comparer = described_class.new surrogate, klass
+ comparer = described_class.new klass, surrogate
comparer.compare[:instance][:types].should == {}
comparer.compare[:class][:types].should == {}
end
it 'ignores methods that are not on both the surrogate and the actual' do
@@ -190,19 +190,19 @@
define(:class_meth2) { |a, b, c| }
end
define(:instance_meth2) { |a, b, c, d| }
end
- described_class.new(surrogate, klass).compare
+ described_class.new(klass, surrogate).compare
comparer.compare[:class][:types].should == {}
comparer.compare[:instance][:types].should == {}
end
it 'ignores methods with no default block' do
klass = Class.new { def instance_meth(a)end }
surrogate = Surrogate.endow(Class.new).define(:instance_meth)
- described_class.new(surrogate, klass).compare
+ described_class.new(klass, surrogate).compare
comparer.compare[:class][:types].should == {}
comparer.compare[:instance][:types].should == {}
end
it 'tells me about class methods with different types' do
@@ -215,11 +215,11 @@
Surrogate.endow self do
define(:class_meth2) { |a, *c, &d| }
end
end
- comparer = described_class.new surrogate, klass
+ comparer = described_class.new klass, surrogate
comparer.compare[:class][:types].should == {
class_meth1: { actual: [:req, :opt, :rest, :block],
surrogate: [ :opt, :rest, :block],
},
class_meth2: { actual: [:req, :opt, :rest, :block],
@@ -237,10 +237,10 @@
surrogate = Class.new parent do
Surrogate.endow self
define(:instance_meth2) { |a, *c, &d| }
end
- comparer = described_class.new surrogate, klass
+ comparer = described_class.new klass, surrogate
comparer.compare[:instance][:types].should == {
instance_meth1: { actual: [:req, :opt, :rest, :block],
surrogate: [ :opt, :rest, :block],
},
instance_meth2: { actual: [:req, :opt, :rest, :block],