Stub user creation in registrations_controller
This commit is contained in:
parent
bc5dc934d6
commit
49e1bde150
2 changed files with 8 additions and 2 deletions
|
|
@ -19,6 +19,10 @@ describe RegistrationsController do
|
|||
|
||||
describe "#create" do
|
||||
context "with valid parameters" do
|
||||
before do
|
||||
user = Factory.build(:user)
|
||||
User.stub!(:build).and_return(user)
|
||||
end
|
||||
it "creates a user" do
|
||||
lambda { get :create, @valid_params }.should change(User, :count).by(1)
|
||||
end
|
||||
|
|
@ -39,6 +43,9 @@ describe RegistrationsController do
|
|||
before do
|
||||
@valid_params["user"]["password_confirmation"] = "baddword"
|
||||
@invalid_params = @valid_params
|
||||
user = Factory.build(:user)
|
||||
user.stub!(:save){user.errors.add_to_base("hello"); false}
|
||||
User.stub!(:build).and_return(user)
|
||||
end
|
||||
it "does not create a user" do
|
||||
lambda { get :create, @invalid_params }.should_not change(User, :count)
|
||||
|
|
@ -53,7 +60,7 @@ describe RegistrationsController do
|
|||
end
|
||||
it "goes back to the form" do
|
||||
get :create, @invalid_params
|
||||
response.should be_redirect
|
||||
response.should redirect_to new_user_registration_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ describe 'making sure the spec runner works' do
|
|||
describe 'factories' do
|
||||
describe 'build' do
|
||||
it 'does not save a built user' do
|
||||
pending 'Why does this happen?'
|
||||
Factory.build(:user).persisted?.should be_false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue