Skip to content

Instantly share code, notes, and snippets.

@Papierkorb
Forked from hxegon/example_stub_problem.rb
Last active December 8, 2015 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Papierkorb/e56273f0da711687f72e to your computer and use it in GitHub Desktop.
Save Papierkorb/e56273f0da711687f72e to your computer and use it in GitHub Desktop.
Having some trouble testing module instance method behavior.
module Foo
def bar
"#{to_s} whizbang"
end
end
describe Foo do
let(:klass) do
Class.new do
include Foo
end
end
subject{ klass.new }
context "#bar" do
it "works" do
expect(subject).to receive(:to_s).and_return "test"
expect(subject.bar).to eq "test whizbang"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment