I am trying to Mock an object that is being passed into another object, and am having no success. Can someone show me what I am doing wrong?
class Fetcher
def download
return 3
end
end
class Reports
def initialize(fetcher)
@fetcher = fetcher
end
def status
@fetcher.download
end
end
describe Reports do
before(:each) do
end
it "should get get status of 6" do
Fetcher.should_receive(:download).and_return(6)
f = Reports.new(Fetcher.new)
f.status.should == 6
end
end
The spec still reports status returning 3, not my intended 6.
Certainly I am missing something here. Any thoughts?