Reputation: 601
I've been trying to create a feature spec with "js: true" for a https page.
I'm using Rails4.2 + rspec + capybara + poltergeist.
I can test http pages with capybara + poltergeist without any problem. However, I can't find a way to test https pages with capybara + poltergeist.
Can anyone guide me on how to accomplish this?
spec/rails_helper.rb
require 'capybara/rspec'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(
app,
phantomjs_options: [
'--debug=no',
'--load-images=no',
'--ignore-ssl-errors=yes',
'--ssl-protocol=TLSv1'
],
debug: false
)
end
https_spec.rb
require 'rails_helper'
RSpec.feature 'https' do
let(:admin) { create(:admin) }
scenario 'display admin dashboard', js: true do
login_as(admin, scope: :user)
visit admin_dashboard_index_path
expect(page).to have_text('TEST')
end
end
I get this message
Failures:
1) https display admin dashboard
Failure/Error: Unable to find matching line from backtrace
RuntimeError:
tried to create a new session when on http, but https is required
Upvotes: 0
Views: 588
Reputation: 261
Maybe this is the solution to your problem:
http://cowjumpedoverthecommodore64.blogspot.com/2013/09/if-your-website-runs-under-ssl-than.html
Upvotes: 1