运行zeus rspec spec/
后,如果有一个使用js:true
的示例,则该命令不会将控制权返回给bash shell。它运行测试并报告结果,但不会退出。但是,如果我只运行rspec
而没有zeus
我可以用这个简单的规范重新创建问题:
require 'spec_helper'
describe "users index" do
before { visit root_path }
it "should not hang", js: true do
expect(page).to have_content("Welcome")
end
end
以下是我spec_helper.rb
的重要部分:
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, inspector: true)
end
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:each) do
DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.infer_base_class_for_anonymous_controllers = false
config.include Capybara::DSL
end
我尝试删除database_cleaner
,但这似乎没有任何影响。
以下是我感兴趣的宝石
ruby '2.0.0'
gem 'rails', '4.0.2'
group :development, :test do
gem 'rspec-rails', '2.14.1'
gem 'guard-rspec', '4.2.3'
gem 'teaspoon', '0.7.7'
gem 'guard-teaspoon', '0.0.4'
gem 'poltergeist', '1.5.0'
gem 'database_cleaner', '1.2.0'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.3.0'
end
我通过phantomjs 1.9.0
brew
答案 0 :(得分:1)
每https://github.com/jonleighton/poltergeist#remote-debugging-experimental,此代码是实验性的:
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, inspector: true)
end
如果我将其删除,那么zeus rspec spec/
会将控制权返回给shell。
解决方案是将实验代码注册为名为:poltergeist_debug
的单独驱动程序:
Capybara.register_driver :poltergeist_debug do |app|
Capybara::Poltergeist::Driver.new(app, inspector: true)
end
Capybara.javascript_driver = :poltergeist
当我需要检查网络浏览器的状态时,和仅临时使用该驱动程序
require 'spec_helper'
Capybara.javascript_driver = :poltergeist_debug
describe "users index" do
before { visit root_path }
it "should not hang", js: true do
page.driver.debug
expect(page).to have_content("Welcome")
end
end
并在zeus之外调试规范