test to see if a method was called

it do
  expect(subject).to receive(:the_method_should_be_called)
  subject.do_something
end
describe "#do_something"
  it do
    # expect to execute the original implementation
    expect(subject).to receive(:the_method_should_be_called).and_call_original
    subject.do_something
  end

  it do
    expect(subject).not_to receive(:the_method_should_be_called)
    subject.do_something
  end
end

Reference

results matching ""

    No results matching ""