search for: post_with_successful_save

Displaying 4 results from an estimated 4 matches for "post_with_successful_save".

2007 Sep 18
2
rSpec / Nested Routes / Mocks
...s_controller_spec-- describe ItemsController, "create action" do before do @item = mock_model(Item, :to_param => "1") @user = mock_model(User, :to_param => "1") Item.stub!(:new).and_return(@course) User.stub!(:find).and_return(@user) end def post_with_successful_save ***** @item.should_receive(:user) @item.should_receive(:save).and_return(true) post :create, :user_id => 1, :item => {} end it "should redirect to the new course on successful save" do post_with_successful_save response.should redirect_to(item_url("1&quot...
2007 Oct 16
2
Does a mock model have to satisfy contraints
I am a little confused to the what happens with the following: before do @site = mock_model(Site, :to_param => "1") Site.stub!(:new).and_return(@site) end def post_with_successful_save @site.should_receive(:save).and_return(true) post :create, :site => {} end I understand that the "@site.should_receive(:save)..." places a check to whether the method is called and that it should return "true", but will the actual method within the model be called,...
2007 Nov 18
9
Not sure why this is failing
...T /users" do before do @address = mock_model(Address, :to_param => "1") @user = mock_model(User, :to_param => "1", :address => @address, :address= => nil) User.stub!(:new).and_return(@user) Address.stub!(:new).and_return(@address) end def post_with_successful_save @user.should_receive(:save).and_return(true) post :create, :user => {} end it "should create a new user" do User.should_receive(:new).with({}).and_return(@user) Address.should_receive(:new).with({}).and_return(@address) <-- Line 245 post_with_successful_s...
2007 Oct 28
2
failing test with nested controller routes
..., I used nested controller so I could have a separate interface for admin. the specs are the same as generated, so I won''t post the whole thing. I did put the nested routes names on the calls to the name routes: it "should redirect to the new group on successful save" do post_with_successful_save response.should redirect_to(admin_group_url("1")) end the error: 1) ''Admin::GroupsController handling POST /admin/groups should redirect to the new group on successful save'' FAILED expected redirect to "http://test.host/admin/groups/1", got redirect to &...