Skip to content

Instantly share code, notes, and snippets.

@mattscilipoti
Created June 24, 2009 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattscilipoti/135307 to your computer and use it in GitHub Desktop.
Save mattscilipoti/135307 to your computer and use it in GitHub Desktop.
cucumber setup
Run all features:
`cucumber`
Run cucumber using selenium:
`cucumber -p selenium features`
TODO: we may be able to clean up the file locations using --exclude in the profiles
default: -r features/support -r features/step_definitions features
selenium: -r features/support -r lib/cucumber_selenium.rb -r features/step_definitions
#Note: we can't put this under the features dir because all files are autoloaded.
#TODO: we may be able to clean up the file locations using --exclude in the profiles
puts 'Loading Cucumber w/Selenium env...'
Webrat.configure do |config|
config.mode = :selenium
# Selenium defaults to using the selenium environment. Use the following to override this.
# config.application_environment = :test
end
# this is necessary to have webrat "wait_for" the response body to be available
# when writing steps that match against the response body returned by selenium
World(Webrat::Selenium::Matchers)
Before do
# truncate your tables here, since you can't use transactional fixtures*
end
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/rails/world'
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
if ENV['DEBUG'] =~ /true/i
puts 'DEBUG=true: Disabling transactions. Use `script/server -e cucumber` to view.'
else
puts "Using transactions. Set DEBUG=true to disable."
Cucumber::Rails.use_transactional_fixtures
end
Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
# (e.g. rescue_action_in_public / rescue_responses / rescue_from)
require 'webrat'
Webrat.configure do |config|
config.mode = :rails
end
require 'cucumber/rails/rspec'
require 'webrat/core/matchers'
#traffipax specific
#require File.expand_path(File.join(RAILS_ROOT, 'spec/shared_spec_helper'))
#database cleaner
#http://github.com/bmabey/database_cleaner/tree/master
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :truncation, {:except => SeedData.seed_tables}
DatabaseCleaner.clean
##traffipax specific
#SeedData.load_all #only needs to be done once, values shouldn't change
Before do
##traffipax specific
# temp_file_dirs = [
# GlobalSettings[:traffidesk_camera_files_root_uri],
# GlobalSettings[:location_staging_root_dir],
# GlobalSettings[:image_folder_root],
# '/home/testftp/usr/bif', #file_steps.test_camera_source_dir
# ]
# temp_file_dirs.each {|dir| rio(dir).delete!.mkpath }
DatabaseCleaner.clean unless Cucumber::Rails::World.use_transactional_fixtures
#traffipax specific
# Factory.reset
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment