added database_cleaner

This commit is contained in:
nilsding 2014-11-18 19:58:14 +01:00
parent 76e6b8f5ec
commit c4d48190b6
4 changed files with 26 additions and 6 deletions

View File

@ -28,7 +28,6 @@ gem 'nprogress-rails'
gem 'font-awesome-rails', '~> 4.2.0.0' gem 'font-awesome-rails', '~> 4.2.0.0'
group :development do group :development do
gem 'thin'
gem 'spring' gem 'spring'
end end
@ -37,12 +36,13 @@ group :production do
end end
group :development, :test do group :development, :test do
gem 'thin'
gem 'rspec-rails', '~> 3.0.0' gem 'rspec-rails', '~> 3.0.0'
gem 'shoulda-matchers'
gem 'factory_girl_rails' gem 'factory_girl_rails'
gem 'faker' gem 'faker'
gem 'capybara' gem 'capybara'
gem 'poltergeist' gem 'poltergeist'
gem 'simplecov' gem 'simplecov'
gem 'database_cleaner'
end end

View File

@ -50,6 +50,7 @@ GEM
execjs execjs
coffee-script-source (1.8.0) coffee-script-source (1.8.0)
daemons (1.1.9) daemons (1.1.9)
database_cleaner (1.3.0)
devise (3.4.1) devise (3.4.1)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
@ -155,8 +156,6 @@ GEM
sdoc (0.4.1) sdoc (0.4.1)
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0) rdoc (~> 4.0)
shoulda-matchers (2.7.0)
activesupport (>= 3.0.0)
simplecov (0.9.1) simplecov (0.9.1)
docile (~> 1.1.0) docile (~> 1.1.0)
multi_json (~> 1.0) multi_json (~> 1.0)
@ -207,6 +206,7 @@ DEPENDENCIES
bootstrap_form bootstrap_form
capybara capybara
coffee-rails (~> 4.1.0) coffee-rails (~> 4.1.0)
database_cleaner
devise devise
factory_girl_rails factory_girl_rails
faker faker
@ -225,7 +225,6 @@ DEPENDENCIES
rspec-rails (~> 3.0.0) rspec-rails (~> 3.0.0)
sass-rails (~> 4.0.3) sass-rails (~> 4.0.3)
sdoc (~> 0.4.1) sdoc (~> 0.4.1)
shoulda-matchers
simplecov simplecov
spring spring
thin thin

View File

@ -24,7 +24,7 @@ RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your # If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false # examples within a transaction, remove the following line or assign false
# instead of true. # instead of true.
config.use_transactional_fixtures = true config.use_transactional_fixtures = false
# RSpec Rails can automatically mix in different behaviours to your tests # RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and # based on their file location, for example enabling you to call `get` and

View File

@ -0,0 +1,21 @@
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end