mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Rewrite some of the .stub calls to use allow
This commit is contained in:
parent
3d775502c8
commit
d0149b1c8f
4 changed files with 8 additions and 7 deletions
|
@ -162,7 +162,7 @@ module Draper
|
|||
|
||||
context "for ActiveModel classes" do
|
||||
it "infers the decorator from the model name" do
|
||||
Product.stub(:model_name).and_return("Other")
|
||||
allow(Product).to receive(:model_name){"Other"}
|
||||
|
||||
expect(Product.decorator_class).to be OtherDecorator
|
||||
end
|
||||
|
|
|
@ -99,7 +99,7 @@ module Draper
|
|||
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
|
||||
|
@ -227,8 +227,8 @@ module Draper
|
|||
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)
|
||||
|
|
|
@ -52,7 +52,7 @@ module Draper
|
|||
view_context = double
|
||||
helper_proxy = HelperProxy.new(view_context)
|
||||
|
||||
view_context.stub(:capture) { |*args, &block| [*args, block.call] }
|
||||
allow(view_context).to receive(:capture) { |*args, &block| [*args, block.call] }
|
||||
expect(helper_proxy.capture(:first_arg, :second_arg){:yielded}).to \
|
||||
be_eql [:first_arg, :second_arg, :yielded]
|
||||
end
|
||||
|
|
|
@ -40,8 +40,9 @@ describe Rails::Generators::DecoratorGenerator do
|
|||
|
||||
context "with an ApplicationDecorator" do
|
||||
before do
|
||||
Object.any_instance.stub(:require).with("application_decorator").and_return (
|
||||
stub_const "ApplicationDecorator", Class.new)
|
||||
allow_any_instance_of(Object).to receive(:require).with("application_decorator").and_return(
|
||||
stub_const "ApplicationDecorator", Class.new
|
||||
)
|
||||
end
|
||||
|
||||
before { run_generator %w(YourModel) }
|
||||
|
|
Loading…
Add table
Reference in a new issue