-
Notifications
You must be signed in to change notification settings - Fork 7
capybara
fushang318 edited this page Aug 14, 2015
·
2 revisions
如果要使用 capybara 的 javascript_driver,建议使用 webkit
要把其使用起来需要进行一些安装和配置
以下是在 debian Wheezy(debian 7) 系统的安装方法
apt-get install libqt4-dev
apt-get install xvfb
其他系统的安装方式请看 https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit
增加以下 gem
group :test do
gem 'database_cleaner', '~> 1.4.1'
gem "factory_girl_rails"
gem 'capybara'
gem "capybara-webkit", '~> 1.6.0'
gem 'headless'
end
rails_helper.rb 中增加以下代码
require 'headless'
headless = Headless.new
headless.start
at_exit { headless.stop }
Capybara.javascript_driver = :webkit
require 'rails_helper'
describe "the signin process", :type => :feature, :js => true do
it "signs me in" do
visit '/sessions/new'
expect(page).to have_css '.js-add'
within("#session") do
fill_in 'Email', :with => 'user@example.com'
fill_in 'Password', :with => 'password'
end
click_button 'Sign in'
expect(page).to have_css '.js-click'
end
end