2010-04-12 23:33:25 +00:00
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2010-07-23 20:09:54 +00:00
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
2010-04-12 23:33:25 +00:00
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
2011-12-06 14:46:21 +00:00
ENV [ 'RAILS_ENV' ] || = 'test'
ENV [ " RAILS_ROOT " ] || = File . join ( File . dirname ( __FILE__ ) , '../' , '../' , 'spec' , 'dummy' )
2010-04-12 23:33:25 +00:00
2011-06-29 01:10:20 +00:00
require 'cucumber/rails'
2010-04-12 23:33:25 +00:00
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/rspec'
require 'cucumber/rails/world'
2011-12-06 14:46:21 +00:00
require 'factory_girl'
2011-06-29 01:10:20 +00:00
require 'capybara'
2010-04-12 23:33:25 +00:00
require 'capybara/rails'
require 'capybara/cucumber'
require 'capybara/session'
2010-07-26 08:19:42 +00:00
2012-04-17 14:13:21 +00:00
require 'json_spec/cucumber'
2011-07-26 20:51:22 +00:00
require 'resolv'
require 'uri'
def ensure_host_resolution ( app_host )
hosts = Resolv :: Hosts . new
app_host_name = URI . parse ( app_host ) . host
begin
hosts . getaddress ( app_host_name )
rescue Resolv :: ResolvError
raise " Unable to resolve ip address for #{ app_host_name } . Please consider adding an entry to '/etc/hosts' that associates #{ app_host_name } with '127.0.0.1'. "
end
end
2011-06-29 01:05:07 +00:00
Capybara . configure do | config |
config . default_selector = :css
2011-07-08 03:51:37 +00:00
config . server_port = 9886
config . app_host = 'http://test.example.com:9886'
2011-07-26 20:51:22 +00:00
ensure_host_resolution ( config . app_host )
2011-06-29 01:05:07 +00:00
end
2010-07-26 08:19:42 +00:00
2012-03-01 10:07:22 +00:00
Capybara . default_wait_time = 5
2011-07-03 00:07:46 +00:00
# Capybara.javascript_driver = :rack_test
2010-04-12 23:33:25 +00:00
2011-06-29 01:05:07 +00:00
# Stop endless errors like
# ~/.rvm/gems/ruby-1.9.2-p0@global/gems/rack-1.2.1/lib/rack/utils.rb:16:
# warning: regexp match /.../n against to UTF-8 string
# more information here: https://github.com/jnicklas/capybara/issues/243
2011-06-29 01:10:20 +00:00
$VERBOSE = nil
2011-06-29 01:05:07 +00:00
# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
2010-04-12 23:33:25 +00:00
#
2011-06-29 01:05:07 +00:00
# 1) Tag your scenario (or feature) with @allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
2011-06-29 01:10:20 +00:00
ActionController :: Base . allow_rescue = false
2011-02-04 09:39:23 +00:00
2011-04-03 23:59:41 +00:00
require File . expand_path ( File . dirname ( __FILE__ ) + '/../../spec/support/carrierwave' )
require File . expand_path ( File . dirname ( __FILE__ ) + '/../../spec/support/locomotive' )
2011-12-06 14:46:21 +00:00
World ( Locomotive :: Engine . routes . url_helpers ) # Load engine routes
2011-11-27 08:29:09 +00:00
Locomotive . configure_for_test ( true )