我想将我的默认驱动器更改为使用 javascript 运行测试,使用 javascript 的特定场景,从默认值:selenium,到任何,如:webkit,在 RSpec 中,只需设置:js => true 标志。但是,尝试使用 :webkit 运行“describe 'xxx', :js => true do”,并在 rspec_helper 中加载 javascript_driver,这就是“Capybara:Module 的未定义方法 javascript_driver”所发生的事情
undefined method `javascript_driver=' for Capybara:Module (NoMethodError)
我是如何在文件 spec_helper.rb 中定义 loader :webkit 的:
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
Capybara.javascript_driver = :webkit
Capybara 的版本是 1.1.2
宝石文件:
source 'https://rubygems.org'
gem 'rails', '3.2.5'
gem 'pg', '0.12.2'
gem "meta_search"
# Bootstrap and layouting
gem 'bootstrap-sass', '2.0.3'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'rails3-jquery-autocomplete'
#test support
gem 'faker', '1.0.1'
#login rules
gem 'devise'
gem 'cancan'
#criptar
gem 'bcrypt-ruby', '3.0.1'
#BR
gem 'brazilian-rails'
gem 'rails-i18n'
group :development do
gem 'annotate', '~> 2.4.1.beta'
gem 'nested_scaffold'
end
group :development, :test do
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '0.5.5'
gem 'guard-spork', '0.3.2'
gem 'spork', '0.9.0'
gem 'ruby-debug19'
gem 'linecache19'
gem 'factory_girl_rails', '1.4.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'capybara', '1.1.2'
gem 'capybara-webkit'
gem "launchy"
gem 'ZenTest'
#MAC OS Especific
gem 'rb-fsevent', '0.4.3.1', :require => false
gem 'growl', '1.0.3'
#Cucumber
gem 'cucumber-rails', '1.2.1', require: false
gem 'database_cleaner', '0.7.0'
end
group :production do
#gem 'pg', '0.12.2'
end
谢谢你先进。