Skip to content

Instantly share code, notes, and snippets.

@henrich-m
Created February 9, 2015 17:58
Show Gist options
  • Save henrich-m/3ee3cc5533dc50fc184d to your computer and use it in GitHub Desktop.
Save henrich-m/3ee3cc5533dc50fc184d to your computer and use it in GitHub Desktop.
capybara-acceptance-test.rb
require "rails_helper"
feature "Signing in" do
background do
FactoryGirl.create(:user)
end
scenario "Signing in with correct credentials" do
visit '/users/sign_in'
within '#new_user' do
fill_in 'email', with: 'henrich@bluemed.com'
fill_in 'password', with: 'password'
end
click_button 'Sign in'
expect(page).to have_content 'Sign out'
end
scenario "Signing in with invalid credentials" do
visit '/users/sign_in'
within '#new_user' do
fill_in 'email', with: 'henrich@bluemed.com'
fill_in 'password', with: 'something'
end
click_button 'Sign in'
expect(page).to have_content 'Invalid email or password'
end
end
feature "Signing Out" do
background do
FactoryGirl.create(:user)
end
scenario "Signing out after a sucesfull sign in" do
visit '/users/sign_in'
within '#new_user' do
fill_in 'email', with: 'henrich@bluemed.com'
fill_in 'password', with: 'password'
end
click_button 'Sign in'
click_link 'Sign out'
expect(page).to have_content 'You need to sign in or sign up before continuing.'
end
end
feature "Sign up" do
scenario "Sign up with new credentials", js: true do
visit '/users/sign_up' do
within '#new_user' do
fill_in 'email', with: 'henrich@bluemed.com'
fill_in 'password', with: 'password'
fill_in 'password confirmation', with: 'password'
end
click_button 'Sign up'
expect(page).to have_content 'Sign out2'
end
end
scenario "Sign up with already registered credentials", js: true do
visit '/users/sign_up' do
within '#new_user' do
fill_in 'email', with: 'henrich@bluemed.com'
fill_in 'password', with: 'dadsadasdas'
fill_in 'password confirmation', with: 'password2'
end
click_button 'Sign up'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment