Facing the question when installing capybara-webkit on Ubuntu 14.04LTS
I am running rails development environment on Ubuntu-14.04 LTS.
I added capybara-webkit to my vendor and ran 'bundle install'.
group :development, :test do
gem 'factory_girl'
gem 'rspec-rails', '~> 3.0'
gem 'capybara'
gem "capybara-webkit"
end
Package installation failed with error. I did the following and tried again ...
sudo apt-get update
sudo apt-get install mesa-common-dev
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
sudo apt-get install libqt4-dev libqtwebkit-dev build-essential
This time the 'bundle install' was successful. Mistake.
I added the following to the "Rails helper" and restarted the rails application.
Capybara.javascript_driver = :webkit
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
I followed the instructions in " http://robots.thoughtbot.com/automatically-wait-for-ajax-with-capybara " and created a file "spec / support / wait_for_ajax.rb" with the following content.
module WaitForAjax
def wait_for_ajax
Timeout.timeout(Capybara.default_wait_time) do
loop until finished_all_ajax_requests?
end
end
def finished_all_ajax_requests?
page.evaluate_script('jQuery.active').zero?
end
end
Then I created a spec file spec / features / guest_login_spec.rb with the following test
feature "Guest attempt login" do
scenario "with valid email and password", js: true do
visit root_path
click_on 'Login'
wait_for_ajax
reload_page
expect(page).to have_css "#login"
end
end
I tried to run the test and got the following error:
Failures:
1) Guest attempt login with valid email and password
Failure/Error: visit root_path
Capybara::Webkit::ConnectionError:
/home/ubuntu/.rvm/gems/ruby-2.0.0-p576/gems/capybara-webkit-1.3.1/bin/webkit_server failed to start.
# /home/ubuntu/.rvm/gems/ruby-2.0.0-p576/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:75:in `parse_port'
I have no idea about this issue. I'm not sure if the issue is with installation or testing or configuration. I tried to find a solution in the forums, but in veins.
I will be very grateful if someone can help me configure capybara-webkit correctly on Ubuntu 14.04LTS and fix this problem.
I use:
OS: Ubuntu 14.04 LTS on x86_64
Rails: 4.1.5
Ruby: 2.0.0p576
Bundler: 1.7.3
Gemfile.lock
$ cat Gemfile.lock | grep capybara
capybara (2.4.4)
capybara-webkit (1.3.1)
capybara (>= 2.0.2, < 2.5.0)
capybara
capybara-webkit
Many thanks,
source to share