Skip to content

Commit d0149b1

Browse files
committed
Rewrite some of the .stub calls to use allow
1 parent 3d77550 commit d0149b1

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

spec/draper/decoratable_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ module Draper
162162

163163
context "for ActiveModel classes" do
164164
it "infers the decorator from the model name" do
165-
Product.stub(:model_name).and_return("Other")
165+
allow(Product).to receive(:model_name){"Other"}
166166

167167
expect(Product.decorator_class).to be OtherDecorator
168168
end

spec/draper/factory_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ module Draper
9999
options = {foo: "bar"}
100100
worker = Factory::Worker.new(double, object)
101101
decorator = ->(*){}
102-
worker.stub decorator: decorator
102+
allow(worker).to receive(:decorator){ decorator }
103103

104104
decorator.should_receive(:call).with(object, options).and_return(:decorated)
105105
expect(worker.call(options)).to be :decorated
@@ -227,8 +227,8 @@ module Draper
227227
it "returns the .decorate_collection method from the object's decorator" do
228228
object = []
229229
decorator_class = Class.new(Decorator)
230-
object.stub decorator_class: decorator_class
231-
object.stub decorate: nil
230+
allow(object).to receive(:decorator_class){ decorator_class }
231+
allow(object).to receive(:decorate){ nil }
232232
worker = Factory::Worker.new(nil, object)
233233

234234
decorator_class.should_receive(:decorate_collection).with(object, foo: "bar", with: nil).and_return(:decorated)

spec/draper/helper_proxy_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module Draper
5252
view_context = double
5353
helper_proxy = HelperProxy.new(view_context)
5454

55-
view_context.stub(:capture) { |*args, &block| [*args, block.call] }
55+
allow(view_context).to receive(:capture) { |*args, &block| [*args, block.call] }
5656
expect(helper_proxy.capture(:first_arg, :second_arg){:yielded}).to \
5757
be_eql [:first_arg, :second_arg, :yielded]
5858
end

spec/generators/decorator/decorator_generator_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040

4141
context "with an ApplicationDecorator" do
4242
before do
43-
Object.any_instance.stub(:require).with("application_decorator").and_return (
44-
stub_const "ApplicationDecorator", Class.new)
43+
allow_any_instance_of(Object).to receive(:require).with("application_decorator").and_return(
44+
stub_const "ApplicationDecorator", Class.new
45+
)
4546
end
4647

4748
before { run_generator %w(YourModel) }

0 commit comments

Comments
 (0)