Fixing up Cucumber env (database_cleaner and envjs)

This commit is contained in:
Jacques Crocker 2010-07-26 01:19:42 -07:00
parent 97551877c0
commit 4eea9855aa
4 changed files with 29 additions and 9 deletions

View File

@ -6,7 +6,6 @@ gem 'rails', '3.0.0.beta4'
gem 'liquid', '2.0.0' gem 'liquid', '2.0.0'
gem 'bson_ext', '>= 1.0.1' gem 'bson_ext', '>= 1.0.1'
gem 'mongo_ext'
gem 'mongoid', "2.0.0.beta11" gem 'mongoid', "2.0.0.beta11"
gem 'mongoid_acts_as_tree', '0.1.5' gem 'mongoid_acts_as_tree', '0.1.5'
gem 'mongo_session_store', '2.0.0.pre' gem 'mongo_session_store', '2.0.0.pre'
@ -43,6 +42,8 @@ group :test do
gem 'rspec-rails', '2.0.0.beta.18' gem 'rspec-rails', '2.0.0.beta.18'
gem 'factory_girl_rails' gem 'factory_girl_rails'
gem 'capybara' gem 'capybara'
gem "capybara-envjs", ">= 0.1.5"
gem 'database_cleaner'
gem 'cucumber' gem 'cucumber'
gem 'cucumber-rails' gem 'cucumber-rails'
gem 'spork' gem 'spork'

View File

@ -66,6 +66,9 @@ GEM
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.3) selenium-webdriver (>= 0.0.3)
capybara-envjs (0.1.6)
capybara (>= 0.3.9)
envjs (>= 0.3.7)
carrierwave-rails3 (0.4.5) carrierwave-rails3 (0.4.5)
cgi_multipart_eof_fix (2.5.0) cgi_multipart_eof_fix (2.5.0)
columnize (0.3.1) columnize (0.3.1)
@ -81,10 +84,13 @@ GEM
cucumber (>= 0.8.0) cucumber (>= 0.8.0)
culerity (0.2.10) culerity (0.2.10)
daemons (1.1.0) daemons (1.1.0)
database_cleaner (0.5.2)
devise (1.1.rc2) devise (1.1.rc2)
bcrypt-ruby (~> 2.1.2) bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7) warden (~> 0.10.7)
diff-lcs (1.1.2) diff-lcs (1.1.2)
envjs (0.3.7)
johnson (>= 2.0.0.pre3)
erubis (2.6.6) erubis (2.6.6)
abstract (>= 1.0.0) abstract (>= 1.0.0)
factory_girl (1.3.1) factory_girl (1.3.1)
@ -116,6 +122,8 @@ GEM
gemcutter (>= 0.1.0) gemcutter (>= 0.1.0)
git (>= 1.2.5) git (>= 1.2.5)
rubyforge (>= 2.0.0) rubyforge (>= 2.0.0)
johnson (2.0.0.pre3)
stackdeck (~> 0.2)
json_pure (1.4.3) json_pure (1.4.3)
launchy (0.3.7) launchy (0.3.7)
configuration (>= 0.0.5) configuration (>= 0.0.5)
@ -130,7 +138,6 @@ GEM
mimetype-fu (0.1.2) mimetype-fu (0.1.2)
mongo (1.0.5) mongo (1.0.5)
bson (>= 1.0.4) bson (>= 1.0.4)
mongo_ext (0.19.3)
mongo_session_store (2.0.0.pre) mongo_session_store (2.0.0.pre)
actionpack (~> 3.0) actionpack (~> 3.0)
mongoid (2.0.0.beta11) mongoid (2.0.0.beta11)
@ -198,6 +205,7 @@ GEM
json_pure json_pure
rubyzip rubyzip
spork (0.8.4) spork (0.8.4)
stackdeck (0.2.0)
term-ansicolor (1.0.5) term-ansicolor (1.0.5)
thor (0.13.8) thor (0.13.8)
treetop (1.4.8) treetop (1.4.8)
@ -224,10 +232,12 @@ DEPENDENCIES
aws aws
bson_ext (>= 1.0.1) bson_ext (>= 1.0.1)
capybara capybara
capybara-envjs (>= 0.1.5)
carrierwave-rails3 carrierwave-rails3
cgi_multipart_eof_fix cgi_multipart_eof_fix
cucumber cucumber
cucumber-rails cucumber-rails
database_cleaner
devise (= 1.1.rc2) devise (= 1.1.rc2)
factory_girl_rails factory_girl_rails
fastthread fastthread
@ -241,7 +251,6 @@ DEPENDENCIES
liquid (= 2.0.0) liquid (= 2.0.0)
mimetype-fu mimetype-fu
mocha! mocha!
mongo_ext
mongo_session_store (= 2.0.0.pre) mongo_session_store (= 2.0.0.pre)
mongoid (= 2.0.0.beta11) mongoid (= 2.0.0.beta11)
mongoid_acts_as_tree (= 0.1.5) mongoid_acts_as_tree (= 0.1.5)

View File

@ -112,7 +112,7 @@ Devise.setup do |config|
# ==> General configuration # ==> General configuration
# Load and configure the ORM. Supports :active_record (default), :mongoid # Load and configure the ORM. Supports :active_record (default), :mongoid
# (requires mongo_ext installed) and :data_mapper (experimental). # and :data_mapper (experimental).
require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/class/attribute'
require 'devise/orm/mongoid' require 'devise/orm/mongoid'

View File

@ -15,12 +15,15 @@ require 'cucumber/web/tableish'
require 'capybara/rails' require 'capybara/rails'
require 'capybara/cucumber' require 'capybara/cucumber'
require 'capybara/session' require 'capybara/session'
require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
require 'capybara/envjs'
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd # order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your # prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax. # steps to use the XPath syntax.
Capybara.default_selector = :css Capybara.default_selector = :css
Capybara.javascript_driver = :envjs
# If you set this to false, any error raised from within your app will bubble # If you set this to false, any error raised from within your app will bubble
# up to your step definition and out to cucumber unless you catch it somewhere # up to your step definition and out to cucumber unless you catch it somewhere
@ -35,12 +38,19 @@ ActionController::Base.allow_rescue = false
require 'factory_girl' require 'factory_girl'
Before do
Mongoid.master.collections.select { |c| c.name != 'system.indexes' }.each(&:drop)
end
Locomotive.configure do |config| Locomotive.configure do |config|
config.default_domain = 'example.com' config.default_domain = 'example.com'
end end
Capybara.default_host = 'test.example.com' Capybara.default_host = 'test.example.com'
# How to clean your database when transactions are turned off. See
# http://github.com/bmabey/database_cleaner for more info.
begin
require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongoid"
rescue LoadError => ignore_if_database_cleaner_not_present
puts "Database Cleaner not Present"
end