Created
February 28, 2011 00:11
-
-
Save niku/846724 to your computer and use it in GitHub Desktop.
How to mocking 'fork' method twice.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
class Foo | |
def my_fork | |
fork do | |
p 'forked once' | |
end | |
end | |
def my_fork_double | |
fork do | |
p 'forked once' | |
fork do | |
p 'forked twice' | |
end | |
end | |
end | |
end | |
describe Foo do | |
subject{ Foo.new } | |
describe '#my_fork' do | |
it 'should call fork' do | |
# Foo.should_receive(:fork) # incorrect | |
subject.should_receive(:fork) | |
subject.my_fork | |
end | |
end | |
describe '#my_fork_double' do | |
subject{ Foo.new } | |
it 'should call fork twice' do | |
pending | |
subject.should_receive(:fork).twice # fail | |
subject.my_fork_double | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment