'Difference between RR mock.instance_of and Mocha any_instance
I have the following rspec code:
require 'spec_helper'
require 'mocha'
require 'rr'
describe ProjectsController, "creating a new project" do
integrate_views
it "should redirect to project with a notice on successful save" do
Project.any_instance.stubs(:valid?).returns(true)
#mock.instance_of(Project).valid? {true}
Project.any_instance.stubs(:create_default_packets)
#mock.instance_of(Project).create_default_packets
post 'create'
assigns[:project].should_not be_new_record
end
end
It passes successfully as written (RR syntax commented out) but when I switch to the RR syntax it fails with:
'ProjectsController creating a new project should redirect to project with a notice on successful save' FAILED expected new_record? to return false, got true
What is the difference between the two that RR would fail?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
