stupid arguments
rspec controller specs:
YourClass.should_receive(:find).with() really cares about argument order and does not accept a hash of values where the params[:key] is named like the key in the hash key => value so:
Yes, I know about hash_including(). For some reason it failed because ":action => '_controller_action_', :only_path => true" was being included in the with() arguments hash and it made the should_receive fail - even though hash_including is supposed to deal with this. It may be a rspec_rails thing. I have not dug into the rspec code very deep to see what I was doing wrong or if it's a bug or if the universe just hates me.
## controller code def find_my_fucking_shit @my_class = MyClass.special_method_in_model(params[:shit], params[:not]) end ## controller spec # This will fail and you will want to punch a bitch in the nose because you spent two fucking days # figuring you were just really goddamn stupid (which may be true) because it should work but it doesn't it "should find shit" do MyClass.should_receive(:special_method_in_model).with({:shit => 'will', :not => 'work'}).and_return(mock_my_shit) get 'find_my_fucking_shit', :shit => 'will', :not => 'work' end # This will pass it "should find shit" do MyClass.should_receive(:special_method_in_model).with('will', 'work').and_return(mock_my_shit) get 'find_my_fucking_shit', :shit => 'will', :not => 'work' end
