Skip to content

Instantly share code, notes, and snippets.

@the-teacher
Created April 19, 2013 06:53
Show Gist options
  • Save the-teacher/5418584 to your computer and use it in GitHub Desktop.
Save the-teacher/5418584 to your computer and use it in GitHub Desktop.
Integration tests
group :development, :test do
gem 'faker'
gem 'rspec'
gem 'rspec-rails'
end
group :test do
gem 'database_cleaner'
gem 'factory_girl_rails'
# integration tests
gem 'capybara'
gem 'poltergeist'
gem 'capybara-webkit'
gem 'selenium-webdriver'
end
PhantomJS
sudo -i
cd /tmp
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
tar xvjf phantomjs-1.9.0-linux-x86_64.tar.bz2
mkdir -p /opt/bin
cp phantomjs-1.9.0-linux-x86_64/bin/phantomjs /opt/bin
echo 'export PATH="$PATH:/opt/bin"' > /etc/profile.d/opt.sh
exit
vi .bash_profile => comment export PATH
QT + Capybara
sudo apt-get install libqt4-dev
gem install capybara-webkit -v '0.14.2'
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/poltergeist'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
Capybara.default_driver = :webkit
# Capybara.default_driver = :selenium
# Capybara.default_driver = :poltergeist
config.infer_base_class_for_anonymous_controllers = false
config.before(:suite) do
DatabaseCleaner[:mongoid].strategy = :truncation
end
config.before(:each) do
DatabaseCleaner[:mongoid].start
end
config.after(:each) do
DatabaseCleaner[:mongoid].clean
end
end
require 'spec_helper'
describe "WebDrivers Test" do
include Capybara::DSL
it "Webkit" do
Capybara.default_driver = :webkit
visit('/')
end
it "Selenium" do
Capybara.default_driver = :selenium
visit('/')
end
it "PhantomJS" do
Capybara.default_driver = :poltergeist
visit('/')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment