Skip to content

Instantly share code, notes, and snippets.

@amo12937
Created October 28, 2015 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amo12937/21b15ee7edb1d34e3b1a to your computer and use it in GitHub Desktop.
Save amo12937/21b15ee7edb1d34e3b1a to your computer and use it in GitHub Desktop.
RSpec x Capybara x Webkit x X Server で JavaScript の絡むテストの自動化 ref: http://qiita.com/amoO_O/items/31d56493887fd0d1edac
DISPLAY="localhost:1.0"
$ bundle install --path vendor/bundle --without=production --binstubs=bundle_bin
$ sudo apt-get install -y libqtwebkit-dev qt4-qmake
$ bundle install --path vendor/bundle --without=production --binstubs=bundle_bin
$ Xvfb :1 -screen 0 1024x768x16 -nolisten inet6
$ export DISPLAY=localhost:1.0
$ rspec
$ sudo apt-get install -y libqtwebkit-dev qt4-qmake
...
Capybara::Webkit::ConnectionError:
... capybara-webkit-1.7.1/bin/webkit_server failed to start.
$ vendor/bundle/ruby/2.2.0/gems/capybara-webkit-1.7.1/bin/webkit_server
webkit_server: cannot connect to X server
$ sudo apt-get install -y xvfb
$ Xvfb :1 -screen 0 1024x768x16 -nolisten inet6
$ export DISPLAY=localhost:1.0
$ rspec
$ sudo apt-get install -y xvfb
group :test do
# ...
gem "capybara-webkit"
# ...
end
config.before :suite do
system "Xvfb :1 -screen 0 1024x768x16 -nolisten inet6 &"
end
config.after :suite do
system "killall Xvfb"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment