Last active
December 20, 2015 22:09
-
-
Save gilles-leblanc/6202940 to your computer and use it in GitHub Desktop.
Simple test to check behaviour of stubs defined with allow.
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_relative 'test_bidon' | |
describe TestBidon do | |
context 'when using stubs' do | |
before :each do | |
@exp = double('exp') | |
allow(@exp).to receive(:name).and_return('Gilles') | |
end | |
it 'is actually called' do | |
@exp.name.should == 'Gilles' | |
end | |
it 'should not return something else' do | |
@exp.name.should_not == 'Bob' | |
end | |
it 'is not called' do | |
puts '' # doing something else | |
end | |
end | |
context 'when using message expectations' do | |
before :each do | |
@exp = double('exp') | |
expect(@exp).to receive(:name).and_return('Gilles') | |
end | |
it 'is actually called' do | |
@exp.name.should == 'Gilles' | |
end | |
it 'should not return something else' do | |
@exp.name.should_not == 'Bob' | |
end | |
it 'is not called' do | |
puts '' # doing something else | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment