tardjo
tardjo

Reputation: 1654

Capybara.javascript_driver = :poltergeist not showing browser during testing

I am trying to test using poltergeist, but the browser is not shown when I run my tests.

This is my spec_helper.rb:

# 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 'rspec/page-regression'

require 'capybara/rspec'
require 'capybara/rails'
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
  #Capybara::Poltergeist::Driver.new(app, {debug: true, :timeout => 90})
  Capybara::Poltergeist::Driver.new(app, {debug: false, :default_wait_time => 30, :timeout => 90})
end
Capybara.javascript_driver = :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|
  # == Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
  config.mock_with :rspec

  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  config.fixture_path = "#{::Rails.root}/spec/fixtures"

  # If you're not using ActiveRecord, or you'd prefer not to run each of your
  # examples within a transaction, remove the following line or assign false
  # instead of true.
  config.use_transactional_fixtures = true
  # config.use_transactional_fixtures = false
  # If true, the base class of anonymous controllers will be inferred
  # automatically. This will be the default behavior in future versions of
  # rspec-rails.
  config.infer_base_class_for_anonymous_controllers = false

  config.include Capybara::DSL
end

# from http://stackoverflow.com/questions/8524839/sending-rails-errors-to-rspec-output
# to output all errors to rspec output
ActionController::Base.class_eval do
  def rescue_action(exception)
    raise exception
  end
end

I don't know if I am correctly setting Capybara.javascript_driver.

Upvotes: 0

Views: 808

Answers (1)

Maksym Melnyk
Maksym Melnyk

Reputation: 96

You won't see the browser. Poltergeist is for headless testing, this means it programmatically renders everything underneath, and programmatically processes interactions with the page.

Upvotes: 6

Related Questions