I have a strange problem with acceptance tests, capybara showing me only first scenario in a browser, all other are just run in back-end and i see a blank page for some reason(but they pass and failed normally). My config is:
require 'capybara'
Capybara.register_driver :selenium_chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.current_driver = :selenium_chrome
Capybara.javascript_driver = :selenium_chrome
Capybara.run_server = true
Capybara.server_port = 7000
Capybara.app_host = "http://localhost:#{Capybara.server_port}"
tests
:
feature 'f1' do
background do
@user = create(:user)
visit "/"
fill_in 'Email', :with => @user.email
fill_in 'Password', :with => 'password'
click_button 'Sign In'
end
scenario "sc1" do
click_link '1'
click_link '2'
click_link '3'
page.should have_content('120')
end
scenario "sc2" do
click_link '4'
click_link '5'
click_link '6'
page.should have_content('110')
end
end
gemfile
:
group :test do
gem 'rspec', '~> 2.8.0'
gem 'rspec-rails', '~> 2.8.0'
gem 'shoulda', '~> 2.11.3'
gem 'shoulda-matchers'
gem 'capybara', '~> 1.1.2'
gem 'nokogiri', '~> 1.5.2'
gem 'database_cleaner'
end
So I can see only sc1
running in browser, sc2
and all others are just run in background and i see a blank page in chrome. Any suggestions?
If someone will meet same problem:
RSpec.configure do |config|
config.before do
Capybara.current_driver = :selenium_chrome
Capybara.javascript_driver = :selenium_chrome
Capybara.run_server = true
Capybara.server_port = 7000
Capybara.app_host = "http://localhost:#{Capybara.server_port}"
end
end
placing this in before
block does the trick