Created
August 18, 2012 18:05
-
-
Save keeperofthenecklace/3388773 to your computer and use it in GitHub Desktop.
spec/requests/user_pages.rb
This file contains 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 pages" do | |
subject { page } | |
describe "profile page" do | |
let(:user) {FactoryGirl.create(:user) } | |
before { visit user_path(user)} | |
it { should have_selector('h1', text: user.name) } | |
it { should have_selector('title', text: user.name) } | |
it { should have_selector('h1', text: 'Sign up') } | |
it { should have_selector('title', text: 'Sign up') } | |
end | |
describe "signup" do | |
before { visit signup_path } | |
let(:submit) { "Create User Account" } | |
describe "with invalid information" do | |
it "should not create a user" do | |
expect { click_button submit }.not_to change(User, :count) | |
end | |
describe "after submission" do | |
before { click_button submit } | |
it { should have_selector('title', text: 'Sign up' )} | |
it { should have_content('error') } | |
end | |
end | |
describe "with valid information" do | |
before do | |
fill_in "Name", with: "Albert Mckeever" | |
fill_in "Email", with: "kotn_ep1@hotmail.com" | |
fill_in "Password", with: "$a36Le" | |
fill_in "Confirmation", with: "$a36Le" | |
end | |
it "should create a user" do | |
expect { click_button submit }.to change(User, :count).by(1) | |
end | |
describe "after saving the user" do | |
before { click_button submit } | |
let(:user) { User.find_by_email('kotn_ep1@hotmail.com') } | |
it { should have_selector( 'title', text: user.name) } | |
it { should have_selector( 'div.alert.alert-success', text: 'Welcome' ) } | |
it { should have_link('Sign out') } | |
end | |
end | |
end | |
describe "edit" do | |
let(:user) { FactoryGirl.create(:user) } | |
before { visit edit_user_path(user) } | |
describe "page" do | |
it { should have_selector('h1', text: "Update your profile")} | |
it { should have_selector('title', text: "Edit user")} | |
it { should have_link('change', href:'http://gravatar.com/emails') } | |
end | |
describe "with invalid information" do | |
before { click_button "Save changes" } | |
it { should have_content('error') } | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment