I try to run some tests with Rspec / Capybara / Poltergeist in my Rails 4 application, Phantomjs is installed (version 2.2.1), but I always get this error:
Error / Error: visit (perfect_landing_page_path)
Capybara :: Poltergeist :: StatusFailError:
The request http : //127.0.0.1-00-009623/path 'could not get to the server, check the DNS and / or server status
The test I'm working on:
require 'rails_helper' RSpec.feature 'Subscription', :type => :feature do let!(:plan) { create(:plan) } let!(:landing_page) { create(:landing_page) } before(:each) { landing_page.default_plan = plan } describe 'landing_page#perfect_show' do scenario 'form display', js: true do plan_2 = create(:plan) plan_3 = create(:plan) landing_page.plans << plan_2 landing_page.plans << plan_3 visit(perfect_landing_page_path) expect(page).to have_css(".start-now", count: 3) first(".start-now").click expect(page).to have_css("#new_user") end end end
My gemfile looks like this:
gem 'rspec-rails', '~> 3.0' gem 'factory_girl_rails' gem 'guard-rspec' group :test do gem 'database_cleaner' gem 'capybara' gem 'capybara-screenshot' gem 'poltergeist' gem 'selenium-webdriver' gem 'shoulda-matchers', require: false gem 'show_me_the_cookies' end
My spec / support / capybara.rb file:
require 'capybara/rails' require 'capybara/rspec' require 'capybara-screenshot/rspec' require "capybara/poltergeist"
My spec_helper.rb file:
require 'capybara/rspec' RSpec.configure do |config| config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true end config.filter_run :focus config.run_all_when_everything_filtered = true
Has anyone encountered this problem before? Does anyone have a solution for this? I hit my head for several days looking on the Internet ... Thank you so much.
PS: it works fine on my other mac (Yosemite or El Capitan), just not on mine.