Skip to content

Instantly share code, notes, and snippets.

@bkempner
Created September 6, 2011 17:30
Show Gist options
  • Save bkempner/1198323 to your computer and use it in GitHub Desktop.
Save bkempner/1198323 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe 'wtf' do
it "doesn't allow non-mocked method calls if any methods are mocked" do
u = User.new
mock(u).first_name
u.first_name
u.last_name
end
# unexpected method call last_name()
# need something like rspec mocks .as_null_object: http://apidock.com/rspec/Spec/Mocks/Methods/as_null_object
# copy and past of spies example: https://github.com/btakita/rr
it "doesn't work with spies" do
subject = Object.new
stub(subject).foo
subject.foo(1)
subject.should have_received.foo(1)
end
# undefined method foo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment