If I have a model
module MyModule
def bar(str)
puts str
end
end
MyModel < ActiveRecord::Base
include MyModule
bar('foo')
end
My spec:
describe MyModel do
before do
described_class.stubs(:bar)
end
it 'calls bar with correct arguments' do
# This does not work because it is called before it gets stubbed
expect(described_class).to have_received(:bar).with('foo')
end
end
How can I spy on MyModule#bar
when called from MyModel
?
Using rspec-rails 2.99 and mocha 0.13.3