Search code examples
ruby-on-railsrspeccapybarapoltergeist

Capybara visit does not load the page


I can't seem to get pages loaded under capybara. The application is namespaced under localhost:3000/secure, but I think that all the settings for there are in place. I see capybara hitting the server log, it seems like it loads the page normally and returns with status 200. However when i try to look at the page the output is always the same, empty html page.

It used to show me the server errors (500 and 404). But once i fixed those in the controller, nothing happens

rspec:

it 'should update the record normally for married status' do
  visit edit_members_bene_partner_path
  save_and_open_page
end

Output of the html is:

<html><head></head><body></body></html>

rspec helper:

# 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 'capybara/rspec'
require 'capybara/rails'
require 'capybara/poltergeist'
require 'capybara-screenshot/rspec'
require 'factory_girl_rails'

# settings for capybara
Capybara.configure do |config|
  config.javascript_driver = :poltergeist
  config.default_wait_time = 5
  config.app_host = 'localhost:3000/secure'
  config.run_server = true
end

RSpec.configure do |config|
  config.include Capybara::DSL
  config.include FactoryGirl::Syntax::Methods
  config.include Rails.application.routes.url_helpers
end

Solution

  • As @Godwin suggested, adding 'http://' to Capybara's config.app_host solved the problen