Created
October 31, 2012 12:22
-
-
Save tarolandia/3986754 to your computer and use it in GitHub Desktop.
Testing create action
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 'spec_helper' | |
describe UsersController do | |
describe "User creation" do | |
it "should create a new user" do | |
@user = mock_model(User, | |
:email => '[email protected]', | |
:password => 'test', | |
:name => 'tester', | |
:username => 'Tester', | |
:birthdate => '1/10/1986', | |
:sex => true | |
) | |
@user.should_receive(:email=) | |
@user.should_receive(:password=) | |
@user.should_receive(:name=) | |
@user.should_receive(:sex=) | |
@user.should_receive(:birthDate=) | |
@user.stub!(:save).and_return(true) | |
User.stub!(:new).and_return(@user) | |
post 'create', :email => @user.email, :password => @user.password, :name => @user.name, :birthdate => @user.birthdate, :sex => @user.sex | |
expect(session[:user]).to_not eq(nil) | |
expect(session[:user].email).to eq(@user.email) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it "should create a new user" do
@user.stub!(:save).and_return(true)
User.stub!(:new).and_return(@user)
post 'create', :email => @user.email, :password => @user.password, :name => @user.name, :birthdate => @user.birthdate, :sex => @user.sex
expect(session[:user]).to_not eq(nil)
expect(session[:user].email).to eq(@user.email)
end