Skip to content

Instantly share code, notes, and snippets.

@szymon-przybyl
Created July 12, 2011 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save szymon-przybyl/1078859 to your computer and use it in GitHub Desktop.
Save szymon-przybyl/1078859 to your computer and use it in GitHub Desktop.
UsersConroller#create spec
describe 'POST create' do
context 'with valid params' do
before(:each) { User.any_instance.stub!(:valid?).and_return(true) }
it 'creates new user and redirects to the home page with a notice' do
post :create, :user => Factory.attributes_for(:user, :username => 'dude')
assigns[:user].should be_persisted
assigns[:user].username.should eq('dude')
flash[:notice].should_not be_nil
response.should redirect_to(root_url)
end
it 'delivers the activation email' do
user = Factory.build(:user)
User.stub!(:new).and_return(user)
user.should_receive(:deliver_activation_instructions!)
post :create
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment