Rails 3.1 capybara javascript test access denied
-
25-10-2019 - |
Question
I've just upgraded to Rails 3.1 and now when I try and run my cucumber (capybara) tests with the @javascript tag I get the following error:
The requested URL could not be retrieved
While trying to retrieve the URL: http://127.0.0.1:9987/login
The following error was encountered
* Access Denied
I have the following defined in my features/support/env.rb file:
if defined?(ActiveRecord::Base)
begin
require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :truncation
rescue LoadError => ignore_if_database_cleaner_not_present
end
end
Capybara.server_port = 9987 + ENV['TEST_ENV_NUMBER'].to_i
Solution
Have you explicitly applied this server port to the Capybara.app_host?
Capybara.app_host = "http://dev.local:#{Capybara.server_port}"
Using this configuration I have no issues with current Rails 3.1 and capybara-webkit.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow