lib/hyper-spec.rb in hyper-spec-0.1.2 vs lib/hyper-spec.rb in hyper-spec-0.99.0
- old
+ new
@@ -1,32 +1,35 @@
require 'capybara/rspec'
-require 'capybara/poltergeist'
require 'opal'
require 'selenium-webdriver'
require 'hyper-spec/component_test_helpers'
-require 'hyper-spec/rails/engine'
require 'hyper-spec/version'
require 'hyper-spec/wait_for_ajax'
-require 'react/isomorphic_helpers'
require 'selenium/web_driver/firefox/profile'
RSpec.configure do |config|
config.include HyperSpec::ComponentTestHelpers
config.include HyperSpec::WaitForAjax
config.include Capybara::DSL
config.mock_with :rspec
- if defined?(HyperMesh)
- config.before(:each) do
- HyperMesh.class_eval do
- def self.on_server?
- true
- end
+ config.add_setting :debugger_width, default: nil
+
+ config.before(:each) do
+ Hyperloop.class_eval do
+ def self.on_server?
+ true
end
- end
+ end if defined?(Hyperloop)
+ # for compatibility with HyperMesh
+ HyperMesh.class_eval do
+ def self.on_server?
+ true
+ end
+ end if defined?(HyperMesh)
end
config.before(:each, js: true) do
size_window
end
@@ -38,51 +41,67 @@
config.after(:each) do |example|
unless example.exception
PusherFake::Channel.reset if defined? PusherFake
end
end
+
end
# Capybara config
RSpec.configure do |_config|
Capybara.default_max_wait_time = 10
- # # In case Google ever fixes chromedriver to work with Opal...
- # Capybara.register_driver :chrome do |app|
- # caps = Selenium::WebDriver::Remote::Capabilities.chrome(
- # 'chromeOptions' => { 'args' => ['--window-size=200,200'] }
- # )
- #
- # Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: caps)
- # end
+ Capybara.register_driver :chrome do |app|
+ options = {}
+ options.merge!(
+ args: %w[auto-open-devtools-for-tabs],
+ prefs: { 'devtools.open_docked' => false, "devtools.currentDockState" => "undocked", devtools: {currentDockState: :undocked} }
+ ) unless ENV['NO_DEBUGGER']
+ # this does not seem to work properly. Don't document this feature yet.
+ options['mobileEmulation'] = { 'deviceName' => ENV['DEVICE'].tr('-', ' ') } if ENV['DEVICE']
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: options)
+ Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
+ end
- Capybara.register_driver :poltergeist do |app|
- options = {
- js_errors: false, timeout: 180, inspector: true,
- phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes']
- }.tap do |hash|
- unless ENV['SHOW_LOGS']
- hash[:phantomjs_logger] = StringIO.new
- hash[:logger] = StringIO.new
- end
- end
+ Capybara.register_driver :chrome_headless_docker_travis do |app|
+ options = ::Selenium::WebDriver::Chrome::Options.new
+ options.add_argument('--headless')
+ options.add_argument('--no-sandbox')
+ options.add_argument('--disable-dev-shm-usage')
+ Capybara::Selenium::Driver.new(app, browser: :chrome, :driver_path => "/usr/lib/chromium-browser/chromedriver", options: options)
+ end
- Capybara::Poltergeist::Driver.new(app, options)
+ Capybara.register_driver :firefox do |app|
+ Capybara::Selenium::Driver.new(app, browser: :firefox)
end
+ Capybara.register_driver :firefox_headless do |app|
+ options = Selenium::WebDriver::Firefox::Options.new
+ options.headless!
+ Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
+ end
+
Capybara.register_driver :selenium_with_firebug do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
- profile.frame_position = ENV['DRIVER'] && ENV['DRIVER'][2]
+ ENV['FRAME_POSITION'] && profile.frame_position = ENV['FRAME_POSITION']
profile.enable_firebug
+ options = Selenium::WebDriver::Firefox::Options.new(profile: profile)
+ Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
+ end
- Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
+ Capybara.register_driver :safari do |app|
+ Capybara::Selenium::Driver.new(app, browser: :safari)
end
Capybara.javascript_driver =
- if ENV['DRIVER'] =~ /^ff/
- :selenium_with_firebug
- # elsif ENV['DRIVER'] == 'chrome'
- # Capybara.javascript_driver = :chrome
- else
- :poltergeist
+ case ENV['DRIVER']
+ when 'beheaded' then :firefox_headless
+ when 'chrome' then :chrome
+ when 'ff' then :selenium_with_firebug
+ when 'firefox' then :firefox
+ when 'headless' then :selenium_chrome_headless
+ when 'safari' then :safari
+ when 'travis' then :chrome_headless_docker_travis
+ else :selenium_chrome_headless
end
+
end