From 49e1bde150dae48bc465adf141275f429b7bd94d Mon Sep 17 00:00:00 2001 From: Raphael <raphael@joindiaspora.com> Date: Fri, 29 Oct 2010 18:46:57 -0700 Subject: [PATCH] Stub user creation in registrations_controller --- spec/controllers/registrations_controller_spec.rb | 9 ++++++++- spec/misc_spec.rb | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index fd1cf4af95..fe6e72d367 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -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 diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index c62920588f..a8e4e4429a 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -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 -- GitLab