Skip to content

Commit

Permalink
Stub user creation in registrations_controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael committed Oct 30, 2010
1 parent bc5dc93 commit 49e1bde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 8 additions & 1 deletion spec/controllers/registrations_controller_spec.rb
Expand Up @@ -19,6 +19,10 @@

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
Expand All @@ -39,6 +43,9 @@
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)
Expand All @@ -53,7 +60,7 @@
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
Expand Down
1 change: 0 additions & 1 deletion spec/misc_spec.rb
Expand Up @@ -35,7 +35,6 @@
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
Expand Down

0 comments on commit 49e1bde

Please sign in to comment.