Created
November 30, 2011 17:04
-
-
Save SeanRoberts/1409826 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "GET galleries/:id/edit" do | |
before do | |
@gallery = mock_model(Gallery).as_null_object | |
@relation = double(ActiveRecord::Relation).as_null_object | |
Gallery.should_receive(:includes).and_return(@relation) | |
@relation.should_receive(:order).and_return(@relation) | |
@relation.should_receive(:find).and_return(@gallery) | |
end | |
it "should assign @gallery" do | |
get :edit, :id => 1 | |
assigns[:gallery].should == @gallery | |
end | |
it "should render the edit template" do | |
get :edit, :id => 1 | |
response.should render_template('edit') | |
end | |
end | |
###### The Action ###### | |
def edit | |
@gallery = Gallery.includes(:photos).order('photos.list_order').find(params[:id]) | |
end | |
# Both specs return: | |
# ActiveRecord::RecordNotFound: | |
# Couldn't find Gallery with id=1 | |
# | |
# I don't understand why the call to find is not being stubbed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment