Created
September 2, 2009 13:45
-
-
Save jhchabran/179720 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
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
describe BabysittersController do | |
integrate_views | |
context "when not authenticated" do | |
RestfulActions.for(BabysittersController) do |action| | |
it "should redirect to root path when accessing ##{action.name}" do | |
send action.method, action.name, action.args | |
response.should redirect_to(root_path) | |
end | |
end | |
end | |
context "when authenticated" do | |
before(:each) do | |
authenticate_user | |
end | |
describe "POST /babysitters/" do | |
context "when succesfully saved" do | |
before(:each) do | |
Babysitter.any_instance.stubs(:valid?).returns(true) | |
post :create | |
end | |
it "should redirect to babysitter_path" do | |
response.should redirect_to(babysitter_path(@user.babysitter.id)) | |
end | |
it "should have a notice" do | |
flash[:notice].should_not be_nil | |
end | |
it "should assign a saved record to @babysitter" do | |
assigns[:babysitter].should_not be_a_new_record | |
end | |
end | |
context "when not succesfully saved" do | |
before(:each) do | |
Babysitter.any_instance.stubs(:valid?).returns(false) | |
post :create | |
end | |
it "should re-render new template" do | |
response.should render_template(:new) | |
end | |
it "should have a notice" do | |
flash[:notice].should_not be_nil | |
end | |
it "should assign a new record to @babysitter" do | |
assigns[:babysitter].should be_a_new_record | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment