Skip to content

Instantly share code, notes, and snippets.

@joonyou
Created September 3, 2013 04:50
Show Gist options
  • Save joonyou/6419807 to your computer and use it in GitHub Desktop.
Save joonyou/6419807 to your computer and use it in GitHub Desktop.
deprecated rspec stub
class Foo
def repeat
2.times { repeated }
end
def repeated; end
end
describe Foo do
let(:foo) { stub method1:"hello" }
context "stub" do
it "is deprecated to use double" do
expect(foo.method1).to eq "hello"
end
end
context "stub!" do
let(:foo) { Foo.new }
it "is deprecated" do
foo.stub! bar:"bar"
expect(foo.bar).to eq "bar"
end
end
context "any_number_of_times" do
it "is deprecated" do
Foo.any_instance.should_receive(:repeated).any_number_of_times
Foo.new.repeat
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment