require "spec_helper" describe SignUpsController do describe "GET new" do it "should show signup form" do get :new assigns(:sign_up).should be_a_new(SignUp) end end describe "POST create" do describe "with valid params" do it "creates a new SignUp" do SignUp.any_instance.should_receive(:subscribe) post :create, { sign_up: { email: "customer@example.com" } } SignUp.count.should == 1 end end describe "with invalid params" do before :each do post :create, { sign_up: { email: "invalidemailaddress" } } end it "goes back to the sign up form with errors" do SignUp.count.should == 0 end it "should display errors" do assigns(:sign_up).errors.count.should > 0 end end end end