Skip to content

Instantly share code, notes, and snippets.

@hxegon
Created December 8, 2015 19:46
Show Gist options
  • Save hxegon/8339dd224a825ec0ba59 to your computer and use it in GitHub Desktop.
Save hxegon/8339dd224a825ec0ba59 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
describe "#bar" do
it "works" do
base = Class.new { include Foo }
# This allow fails saying base doesn't implement :read
allow(base).to receive(:to_s) { "test" }
expect(base.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