Topic: Creating stubs for any_instance affect other tests
Hi,
I'm a rails and BDD newbie, while working on some samples I had the following issue using Mocha gem
I had a passing test as follows
test "should create project" do
assert_difference('Project.count') do
post :create, :project => @project.attributes
end
assert_redirected_to project_path(assigns(:project))
end
when I added the following test
test "fail create gracefully" do
assert_no_difference('Project.count') do
Project.any_instance.stubs(:save).returns(false)
post :create, :project => {:name => 'Project Runaway'}
assert_template('new')
end
end
The first test failed
It looks like that the object stub affected the behavior of other tests
I feel it is a silly question but I really appreciate if someone would help to understand how to overcome this issue
Last edited by jwahba (2010-10-27 07:45:27)