Capybara::Poltergeist::StatusFailError: failed to reach server
bennypaulino opened this issue · comments
I'm new to using Poltergeist. Attempts to resolve hostname issues for the call to root_url(...) have been commented out in the relevant files below. These approaches and the current state are met with the following error:
Issue...
1) subdomains redirects invalid accounts
Failure/Error: visit root_url(subdomain: 'random-subdomain')
Capybara::Poltergeist::StatusFailError:
Request to 'http://random-subdomain.example.com/' failed to reach server, check DNS and/or server status
# /home/benny/.rvm/gems/ruby-2.3.3/gems/poltergeist-1.14.0/lib/capybara/poltergeist/browser.rb:376:in `command'
# /home/benny/.rvm/gems/ruby-2.3.3/gems/poltergeist-1.14.0/lib/capybara/poltergeist/browser.rb:35:in `visit'
# /home/benny/.rvm/gems/ruby-2.3.3/gems/poltergeist-1.14.0/lib/capybara/poltergeist/driver.rb:97:in `visit'
# /home/benny/.rvm/gems/ruby-2.3.3/gems/capybara-2.13.0/lib/capybara/session.rb:254:in `visit'
# /home/benny/.rvm/gems/ruby-2.3.3/gems/capybara-2.13.0/lib/capybara/dsl.rb:52:in `block (2 levels) in <module:DSL>'
# ./spec/features/subdomain_feature_spec.rb:8:in `block (2 levels) in <top (required)>'
Version Info:
- phantomjs 2.1.1
- poltergeist 1.14.0
- capybara 2.13.0
- rails 4.2.8
- ruby 2.3.3
- linux mint 17.3
subdomain_feature_spec.rb
require 'rails_helper'
describe 'subdomains' do
let!(:account) { create(:account_with_schema) }
# let(:random) {"http://random-subdomain.lvh.me:3001"}
it 'redirects invalid accounts', :js => true do
visit root_url(subdomain: 'random-subdomain')
# visit random
# visit root_path(subdomain: 'random-subdomain')
expect(page.current_url).not_to have_current_path(/random-subdomain/, url: true)
# expect(response).to redirect_to root_url
end
end
spec/rails_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__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
# Add additional requires below this line. Rails is not loaded until this point!
require 'spec_helper'
require 'rspec/rails'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
# lvh.me resolves to 127.0.0.1
# Capybara.app_host = "http://lvh.me/"
# Capybara.server_port = 3001
# Capybara.app_host = 'http://random-subdomain.example.com:3001'
# Capybara.register_driver :poltergeist do |app|
# Capybara::Poltergeist::Driver.new(app, timeout: 60)
# end
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = false
config.infer_spec_type_from_file_location!
config.include FactoryGirl::Syntax::Methods
# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
end
spec/spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'shoulda/matchers'
require 'rspec/autorun'
require 'database_cleaner'
require 'capybara/rspec'
require 'coveralls'
Coveralls.wear!
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
Capybara.app_host = 'http://example.com'
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
#config.include Devise::TestHelpers, type: :controller
config.include Rails.application.routes.url_helpers
config.order = "random"
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
Apartment::Tenant.reset
drop_schemas
end
end
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
This resource proved helpful in solving this issue:
https://gist.github.com/turadg/5399790