Created
October 31, 2020 20:37
-
-
Save shen-sat/c2204ec3a4583f9f6bf29680943009f1 to your computer and use it in GitHub Desktop.
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
class Foo | |
attr_reader :bar | |
def change_bar | |
bar ? @bar = false : @bar = true | |
end | |
end | |
describe 'Foo' do | |
let(:foo) { Foo.new } | |
describe '#change_bar' do | |
context 'when bar is true' do | |
before { allow(foo).to receive(:bar).and_return(true) } | |
it 'sets bar to false' do | |
foo.change_bar | |
allow(foo).to receive(:bar).and_call_original #this line is ugly | |
expect(foo.bar).to eq(false) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment