Skip to content

Instantly share code, notes, and snippets.

@shen-sat
Created October 31, 2020 20:37
Show Gist options
  • Save shen-sat/c2204ec3a4583f9f6bf29680943009f1 to your computer and use it in GitHub Desktop.
Save shen-sat/c2204ec3a4583f9f6bf29680943009f1 to your computer and use it in GitHub Desktop.
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