Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to selenium-webdriver #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ If you're using Cucumber, add this too:
end

It is advised to run your tests with `js: true` (RSpec) or `@javascript`
(Cucumber), so that the requests correctly go through `FakeBraintree`. You might
want to take a look at
[capybara-webkit](https://github.com/thoughtbot/capybara-webkit).
(Cucumber), so that the requests correctly go through `FakeBraintree`.

## Don't set the Braintree environment

Expand Down
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'net/http'
require 'capybara'
require 'capybara-webkit'
require 'yaml'

RSpec::Core::RakeTask.new(:spec)
Expand All @@ -28,7 +27,7 @@ task :update_dropin do
puts 'Determining drop-in version from client code'
uri = URI('https://js.braintreegateway.com/v2/braintree.js')
js_client = Net::HTTP.get(uri)
session = Capybara::Session.new(:webkit, ->{})
session = Capybara::Session.new(:chrome_headless, ->{})
session.execute_script(js_client)
client_version = session.evaluate_script('braintree.VERSION')
dropin_version = session.evaluate_script('braintree.dropin.VERSION')
Expand Down
6 changes: 4 additions & 2 deletions fake_braintree.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ Gem::Specification.new do |s|
s.add_dependency 'capybara', '>= 2.2.0'
s.add_dependency 'sinatra'

s.add_development_dependency 'puma'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec', '~> 3.2'
s.add_development_dependency 'rspec'
s.add_development_dependency 'selenium-webdriver'
s.add_development_dependency 'timecop', '~> 0.6'
s.add_development_dependency 'capybara-webkit'
s.add_development_dependency 'webdrivers'
end
2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
require 'fake_braintree'
require 'timecop'
require 'dummy/checkout_app'
require 'capybara-webkit'

FakeBraintree.activate!

Expand All @@ -13,7 +12,6 @@
TEST_CC_NUMBER = %w(4111 1111 1111 1111).join

Capybara.app = CheckoutApp
Capybara.javascript_driver = :webkit

RSpec.configure do |config|
config.mock_with :rspec do |mocks|
Expand Down
13 changes: 13 additions & 0 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'webdrivers'
Webdrivers::Chromedriver.update

Capybara.register_driver :chrome_headless do |app|
Capybara::Selenium::Driver.load_selenium

browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
opts.args << '--headless'
end
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end

Capybara.javascript_driver = :chrome_headless