Created
December 11, 2012 09:25
-
-
Save deepflame/4257276 to your computer and use it in GitHub Desktop.
Rspec, Capybara, PhantomJs sample config for headless non-Rails-app testing
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
source :rubygems | |
gem 'rspec' | |
gem 'capybara' | |
gem 'poltergeist' # Capybara driver for PhantomJs | |
gem 'capybara-screenshot', :require => false # takes screenshots when test fails | |
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 | |
remote: http://rubygems.org/ | |
specs: | |
addressable (2.3.2) | |
capybara (1.1.4) | |
mime-types (>= 1.16) | |
nokogiri (>= 1.3.3) | |
rack (>= 1.0.0) | |
rack-test (>= 0.5.4) | |
selenium-webdriver (~> 2.0) | |
xpath (~> 0.1.4) | |
capybara-screenshot (0.2.4) | |
capybara (>= 1.0) | |
childprocess (0.3.6) | |
ffi (~> 1.0, >= 1.0.6) | |
diff-lcs (1.1.3) | |
eventmachine (1.0.0) | |
faye-websocket (0.4.6) | |
eventmachine (>= 0.12.0) | |
ffi (1.2.0) | |
http_parser.rb (0.5.3) | |
libwebsocket (0.1.7.1) | |
addressable | |
websocket | |
mime-types (1.19) | |
multi_json (1.5.0) | |
nokogiri (1.5.5) | |
poltergeist (1.0.2) | |
capybara (~> 1.1) | |
childprocess (~> 0.3) | |
faye-websocket (~> 0.4, >= 0.4.4) | |
http_parser.rb (~> 0.5.3) | |
multi_json (~> 1.0) | |
rack (1.4.1) | |
rack-test (0.6.2) | |
rack (>= 1.0) | |
rspec (2.12.0) | |
rspec-core (~> 2.12.0) | |
rspec-expectations (~> 2.12.0) | |
rspec-mocks (~> 2.12.0) | |
rspec-core (2.12.1) | |
rspec-expectations (2.12.0) | |
diff-lcs (~> 1.1.3) | |
rspec-mocks (2.12.0) | |
rubyzip (0.9.9) | |
selenium-webdriver (2.27.1) | |
childprocess (>= 0.2.5) | |
libwebsocket (~> 0.1.3) | |
multi_json (~> 1.0) | |
rubyzip | |
websocket (1.0.4) | |
xpath (0.1.4) | |
nokogiri (~> 1.3) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
capybara | |
capybara-screenshot | |
poltergeist | |
rspec |
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 "the Openit Website", :type => 'request' do | |
before :each do | |
visit "http://www.openit.com" | |
end | |
it "has Products" do | |
click_on 'Products' | |
page.should have_content "Open iT Base and Modules" | |
end | |
# this test is supposed to fail | |
it "has Pizza" do | |
click_on 'Pizza' | |
page.should have_content "Mozzarella" | |
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
require 'rubygems' | |
require 'bundler/setup' | |
require 'rspec/autorun' | |
require 'capybara/rspec' | |
require 'capybara-screenshot' | |
require 'capybara-screenshot/rspec' | |
require 'capybara/poltergeist' | |
Capybara.register_driver :poltergeist do |app| | |
Capybara::Poltergeist::Driver.new(app, :inspector => true) | |
end | |
Capybara.default_driver = :poltergeist | |
Capybara.javascript_driver = :poltergeist | |
Capybara.default_selector = :css | |
Capybara.run_server = false | |
# Requires supporting ruby files with custom matchers and macros, etc, | |
# in spec/support/ and its subdirectories. | |
Dir["spec/support/**/*.rb"].each {|f| require f} | |
# Additional RSpec config | |
RSpec.configure do |config| | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment