Created
October 31, 2011 04:41
-
-
Save azuby/1326931 to your computer and use it in GitHub Desktop.
User Request Spec
This file contains hidden or 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 "User" do | |
| describe "signup" do | |
| describe "failure" do | |
| it "should not make a new user" do | |
| lambda do | |
| visit new_user_registration_path | |
| fill_in :user_first_name, :with => "" | |
| fill_in :user_last_name, :with => "" | |
| fill_in :user_company_id, :with => "" | |
| fill_in :user_email, :with => "" | |
| fill_in :user_password, :with => "" | |
| fill_in :user_password_confirmation, :with => "" | |
| click_button | |
| response.should render_template('users/registrations/new') | |
| response.should have_selector("div#error_explanation") | |
| end.should_not change(User, :count) | |
| end | |
| end # describe failure | |
| describe "success" do | |
| it "should make a new user" do | |
| lambda do | |
| visit new_user_registration_path | |
| fill_in :user_first_name, :with => "Example" | |
| fill_in :user_last_name, :with => "User" | |
| fill_in :user_company_id, :with => 1 | |
| fill_in :user_email, :with => "user@example.com" | |
| fill_in :user_password, :with => "secret" | |
| fill_in :user_password_confirmation, :with => "secret" | |
| click_button | |
| response.should have_selector("div.flash", | |
| :content => "Welcome") | |
| response.should render_template('/') | |
| end.should change(User, :count).by(1) | |
| end | |
| end # describe success | |
| end # describe signup | |
| describe "sign in/out" do | |
| describe "failure" do | |
| it "should not sign a user in" do | |
| visit new_user_session_path | |
| fill_in :email, :with => "" | |
| fill_in :password, :with => "" | |
| click_button | |
| response.should have_selector("div.flash", :content => "Invalid") | |
| end | |
| end # describe failure | |
| describe "success" do | |
| it "should sign a user in and out" do | |
| user = Factory(:user) | |
| visit new_user_session_path | |
| fill_in :email, :with => user.email | |
| fill_in :password, :with => user.password | |
| click_button | |
| controller.should be_signed_in | |
| click_link "Sign Out", :method => :delete | |
| #controller.should_not be_signed_in | |
| end | |
| end # describe success | |
| end # describe sign in/out | |
| end # describe Users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment