env.rb revision d327eb79653cf7820fe583473ab35816d44cd757
52N/A# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
52N/A# It is recommended to regenerate this file in the future when you upgrade to a
292N/A# newer version of cucumber-rails. Consider adding your own code to a new file
52N/A# instead of editing this one. Cucumber will automatically load all features/**/*.rb
52N/A# files.
514N/Arequire 'simplecov'
52N/Arequire 'sidekiq/testing'
52N/Arequire 'cucumber/rails'
52N/Arequire 'capybara/poltergeist'
52N/Arequire 'webmock'
292N/Arequire 'vcr'
292N/A
292N/ACapybara.current_driver = :poltergeist
292N/ACapybara.javascript_driver = :poltergeist
52N/ACapybara.default_max_wait_time = 5
52N/A
52N/Aclass Cucumber::Rails::World
292N/A require Rails.root.join('spec', 'support', 'common_helper_methods.rb')
292N/A require Rails.root.join('spec', 'support', 'scenario_progress_formatter.rb')
292N/A require Rails.root.join('spec', 'support', 'shared_helper.rb')
292N/A
292N/A # Capybara is smart enough to wait for ajax when not finding elements.
292N/A # In some situations the element is already existent, but has not been updated
292N/A # yet. This is where you need to manually use wait_for_ajax.
292N/A def wait_for_ajax
292N/A counter = 0
292N/A # The condition only works with poltergeist/phantomjs.
292N/A while page.evaluate_script("jQuery.active").to_i > 0
52N/A counter += 1
52N/A sleep(0.1)
52N/A if counter >= 10 * Capybara.default_max_wait_time
52N/A raise "AJAX request took longer than 5 seconds."
52N/A end
52N/A end
52N/A end
52N/Aend
52N/A
52N/A
52N/A# Capybara defaults to CSS3 selectors rather than XPath.
52N/A# If you'd prefer to use XPath, just uncomment this line and adjust any
292N/A# selectors in your step definitions to use the XPath syntax.
52N/A# Capybara.default_selector = :xpath
52N/A
6N/A# By default, any exception happening in your Rails application will bubble up
6N/A# to Cucumber so that your scenario will fail. This is a different from how
6N/A# your application behaves in the production environment, where an error page will
6N/A# be rendered instead.
377N/A#
377N/A# Sometimes we want to override this default behaviour and allow Rails to rescue
377N/A# exceptions and display an error page (just like when the app is running in production).
377N/A# Typical scenarios where you want to do this is when you test your error pages.
377N/A# There are two ways to allow Rails to rescue exceptions:
6N/A#
15N/A# 1) Tag your scenario (or feature) with @allow-rescue
6N/A#
6N/A# 2) Set the value below to true. Beware that doing this globally is not
558N/A# recommended as it will mask a lot of errors for you!
6N/A#
15N/AActionController::Base.allow_rescue = false
549N/A
6N/A# Remove/comment out the lines below if your app doesn't have a database.
377N/A# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
549N/Abegin
549N/A DatabaseCleaner.strategy = :transaction
549N/Arescue NameError
377N/A raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
377N/Aend
377N/A
377N/A# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
377N/A# See the DatabaseCleaner documentation for details. Example:
377N/A#
377N/A# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
6N/A# # { :except => [:widgets] } may not do what you expect here
6N/A# # as Cucumber::Rails::Database.javascript_strategy overrides
549N/A# # this setting.
467N/A# DatabaseCleaner.strategy = :truncation
467N/A# end
549N/A#
6N/A# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
6N/A# DatabaseCleaner.strategy = :transaction
6N/A# end
6N/A#
302N/A
302N/A# Possible values are :truncation and :transaction
6N/A# The :transaction strategy is faster, but might give you threading problems.
6N/A# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
6N/ACucumber::Rails::Database.javascript_strategy = :transaction
558N/A
121N/A# We need to establish the basic entries in the database
558N/AFactoryGirl.create :proof_statuses
525N/A
6N/AWebMock.allow_net_connect!(:net_http_connect_on_start => true)
15N/A
15N/Ainclude Warden::Test::Helpers
15N/AWarden.test_mode!
15N/A
15N/ATest::Unit::AutoRunner.need_auto_run = false if defined?(Test::Unit::AutoRunner)
15N/ATest::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
15N/A