bundle exec script/degenerate!

This commit is contained in:
Dan Buch 2012-03-07 00:46:33 -05:00
parent ee337ba7ee
commit dd73309ed1

View File

@ -1,131 +1,4 @@
require 'spec_helper'
describe MashesController do
def mock_mash(stubs={})
@mock_mash ||= mock_model(Mash, stubs)
end
describe "GET index" do
it "assigns all mashes as @mashes" do
Mash.stub(:find).with(:all).and_return([mock_mash])
get :index
assigns[:mashes].should == [mock_mash]
end
end
describe "GET show" do
it "assigns the requested mash as @mash" do
Mash.stub(:find).with("37").and_return(mock_mash)
get :show, :id => "37"
assigns[:mash].should equal(mock_mash)
end
end
describe "GET new" do
it "assigns a new mash as @mash" do
Mash.stub(:new).and_return(mock_mash)
get :new
assigns[:mash].should equal(mock_mash)
end
end
describe "GET edit" do
it "assigns the requested mash as @mash" do
Mash.stub(:find).with("37").and_return(mock_mash)
get :edit, :id => "37"
assigns[:mash].should equal(mock_mash)
end
end
describe "POST create" do
describe "with valid params" do
it "assigns a newly created mash as @mash" do
Mash.stub(:new).with({'these' => 'params'}).and_return(mock_mash(:save => true))
post :create, :mash => {:these => 'params'}
assigns[:mash].should equal(mock_mash)
end
it "redirects to the created mash" do
Mash.stub(:new).and_return(mock_mash(:save => true))
post :create, :mash => {}
response.should redirect_to(mash_url(mock_mash))
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved mash as @mash" do
Mash.stub(:new).with({'these' => 'params'}).and_return(mock_mash(:save => false))
post :create, :mash => {:these => 'params'}
assigns[:mash].should equal(mock_mash)
end
it "re-renders the 'new' template" do
Mash.stub(:new).and_return(mock_mash(:save => false))
post :create, :mash => {}
response.should render_template('new')
end
end
end
describe "PUT update" do
describe "with valid params" do
it "updates the requested mash" do
Mash.should_receive(:find).with("37").and_return(mock_mash)
mock_mash.should_receive(:update_attributes).with({'these' => 'params'})
put :update, :id => "37", :mash => {:these => 'params'}
end
it "assigns the requested mash as @mash" do
Mash.stub(:find).and_return(mock_mash(:update_attributes => true))
put :update, :id => "1"
assigns[:mash].should equal(mock_mash)
end
it "redirects to the mash" do
Mash.stub(:find).and_return(mock_mash(:update_attributes => true))
put :update, :id => "1"
response.should redirect_to(mash_url(mock_mash))
end
end
describe "with invalid params" do
it "updates the requested mash" do
Mash.should_receive(:find).with("37").and_return(mock_mash)
mock_mash.should_receive(:update_attributes).with({'these' => 'params'})
put :update, :id => "37", :mash => {:these => 'params'}
end
it "assigns the mash as @mash" do
Mash.stub(:find).and_return(mock_mash(:update_attributes => false))
put :update, :id => "1"
assigns[:mash].should equal(mock_mash)
end
it "re-renders the 'edit' template" do
Mash.stub(:find).and_return(mock_mash(:update_attributes => false))
put :update, :id => "1"
response.should render_template('edit')
end
end
end
describe "DELETE destroy" do
it "destroys the requested mash" do
Mash.should_receive(:find).with("37").and_return(mock_mash)
mock_mash.should_receive(:destroy)
delete :destroy, :id => "37"
end
it "redirects to the mashes list" do
Mash.stub(:find).and_return(mock_mash(:destroy => true))
delete :destroy, :id => "1"
response.should redirect_to(mashes_url)
end
end
end