spec/draper/factory_spec.rb in draper-2.1.0 vs spec/draper/factory_spec.rb in draper-3.0.0.pre1
- old
+ new
@@ -97,11 +97,11 @@
it "calls the decorator method" do
object = double
options = {foo: "bar"}
worker = Factory::Worker.new(double, object)
decorator = ->(*){}
- worker.stub decorator: decorator
+ allow(worker).to receive(:decorator){ decorator }
decorator.should_receive(:call).with(object, options).and_return(:decorated)
expect(worker.call(options)).to be :decorated
end
@@ -225,11 +225,11 @@
context "when decorator_class is unspecified" do
context "and the object is decoratable" do
it "returns the .decorate_collection method from the object's decorator" do
object = []
decorator_class = Class.new(Decorator)
- object.stub decorator_class: decorator_class
- object.stub decorate: nil
+ allow(object).to receive(:decorator_class){ decorator_class }
+ allow(object).to receive(:decorate){ nil }
worker = Factory::Worker.new(nil, object)
decorator_class.should_receive(:decorate_collection).with(object, foo: "bar", with: nil).and_return(:decorated)
expect(worker.decorator.call(object, foo: "bar")).to be :decorated
end