i'm calling a very simple should_receive method on a returned instance and it's saying the implementation code is not calling it. i get this error in my specs alot. i've read the rspec beta book and it doesn't mention examples like this. i couldn't find any solutions on the forum yet so i wanted to reach out. it seems like i'm just not getting something about the rspec api.
==SPEC== before :all do @scene = Factory.create(:scene) @project = Project.create(:working_title => "test") @project.scenes << [...@scene] @project.save end it 'should call done! on @scene' do @project.stub_chain(:scenes, :find).and_return(@scene) @scene.should_receive(:done!).and_return(true) xhr :post, :done, {:id => @scene.id, :project_id => @project.id} end ==IMPLEMENTATION== class ScenesController < ApplicationController before_filter :get_project def done @scene = @project.scenes.find(params[:id]) if @scene.done! render else render_alert("Scene cannot be marked done.") end end end ==OUTPUT== Spec::Mocks::MockExpectationError in 'ScenesController#done #<Scene:0x105a90708> expected :done! with (any args) once, but received it 0 times note: @project is assigned through a before_filter (defined in ApplicationController) which finds the project using params[:project_id]. it's a nested resources thang... you know this isn't specific to the state machine plugin. it's the same for any instance i return from another operation within a spec. it's as though the @scene returned isn't receving anything, but some other @scene (somewhere else) is receving the done! method just fine. the sad part is, even though the spec fails, the code works in production. decouplization does come with headaches. any help with my practices wrong would definitely be appreciated and probably clear up the same issue a dozen other times in the code. thank you all. VERSIONS osx 10.6.2 rspec 1.3 rspec-rails 1.3.2 rails 2.3.5 factory-girl 1.2.2 aasm plugin _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users