Last active
August 29, 2015 14:02
-
-
Save forest/f507a636f35ef329b5f9 to your computer and use it in GitHub Desktop.
SauceLabs Spec Helper
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
gem 'sauce', group: [:development, :sauce] | |
group :sauce do | |
gem 'rspec' | |
gem 'rspec-instafail' | |
gem 'capybara' | |
# gem 'parallel_tests' | |
gem 'ci_reporter' | |
gem 'sauce-connect' | |
end |
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 'sauce_spec_helper' | |
require_relative 'page_objects/login_page' | |
feature 'Login Page', :sauce => ENV['RUN_ON_SAUCE'] do | |
given(:login_page) { PageObjects::LoginPage.new } | |
background do | |
login_page.visit | |
end | |
scenario "Should log in user with valid credentials" do | |
login_page.login('active', 'test123') | |
login_page.verify_logged_in_and_redirected | |
end | |
scenario "Shouldn't log in invalid user" do | |
login_page.login('invalid_email', 'password') | |
login_page.verify_alert('Invalid email or password.') | |
end | |
scenario "Shouldn't log in user with no password" do | |
login_page.login('invalid_email', '') | |
login_page.verify_alert('Invalid email or password.') | |
end | |
scenario "Shouldn't log in user with no email/username" do | |
login_page.login('', 'password') | |
login_page.verify_alert('Sorry, unrecognized username or password.') | |
end | |
scenario "Shouldn't log in user with no credentials" do | |
login_page.login('', '') | |
login_page.verify_alert('Sorry, unrecognized username or password.') | |
end | |
end |
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
RUN_ON_SAUCE=true bundle exec rspec spec/integration/login_spec.rb |
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
ENV['RAILS_ENV'] ||= 'test' | |
require 'rubygems' | |
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | |
require 'bundler/setup' | |
Bundler.require(:sauce) | |
require 'rspec' | |
require 'capybara/rspec' | |
require 'sauce' | |
require 'sauce/capybara' | |
if ENV['RUN_ON_SAUCE'] == 'true' | |
Capybara.default_driver = :sauce | |
Capybara.javascript_driver = :sauce | |
else | |
Capybara.default_driver = :selenium | |
Capybara.javascript_driver = :integration | |
end | |
# You should edit this file with the browsers you wish to use | |
# For options, check out http://saucelabs.com/docs/platforms | |
Sauce.config do |config| | |
# Use browsers defined by Jenkins Job if set | |
if ENV['SAUCE_ONDEMAND_BROWSERS'] | |
browsers = JSON.parse(ENV['SAUCE_ONDEMAND_BROWSERS']) | |
config[:browsers] = browsers.map { |x| [x['os'], x['browser'], x['browser-version']] } | |
else | |
config[:browsers] = [ | |
['Windows 7', 'Internet Explorer', '9'] | |
] | |
end | |
config[:start_tunnel] = false | |
config[:start_local_application] = false | |
config[:record_video] = true | |
config[:application_host] = ENV['APP_HOST'] || "mysite.com" | |
config[:application_port] = ENV['APP_PORT'] | |
config[:browser_url] = "http://#{config[:application_host]}" | |
config[:browser_url] += ":#{config[:application_port]}" if config[:application_port] | |
end | |
# Set the root URL for specs | |
Capybara.app_host = Sauce.get_config[:browser_url] | |
Capybara.default_wait_time = 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment