diff --git a/Gemfile b/Gemfile index 188ecbc4..705d9f6e 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,6 @@ gem 'nprogress-rails' gem 'font-awesome-rails', '~> 4.2.0.0' group :development do - gem 'thin' gem 'spring' end @@ -37,12 +36,13 @@ group :production do end group :development, :test do + gem 'thin' gem 'rspec-rails', '~> 3.0.0' - gem 'shoulda-matchers' gem 'factory_girl_rails' gem 'faker' gem 'capybara' gem 'poltergeist' gem 'simplecov' + gem 'database_cleaner' end diff --git a/Gemfile.lock b/Gemfile.lock index 1f23ed11..05abc76e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,6 +50,7 @@ GEM execjs coffee-script-source (1.8.0) daemons (1.1.9) + database_cleaner (1.3.0) devise (3.4.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -155,8 +156,6 @@ GEM sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - shoulda-matchers (2.7.0) - activesupport (>= 3.0.0) simplecov (0.9.1) docile (~> 1.1.0) multi_json (~> 1.0) @@ -207,6 +206,7 @@ DEPENDENCIES bootstrap_form capybara coffee-rails (~> 4.1.0) + database_cleaner devise factory_girl_rails faker @@ -225,7 +225,6 @@ DEPENDENCIES rspec-rails (~> 3.0.0) sass-rails (~> 4.0.3) sdoc (~> 0.4.1) - shoulda-matchers simplecov spring thin diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ecb15e3d..5bbadc73 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -24,7 +24,7 @@ RSpec.configure do |config| # 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 # instead of true. - config.use_transactional_fixtures = true + config.use_transactional_fixtures = false # RSpec Rails can automatically mix in different behaviours to your tests # based on their file location, for example enabling you to call `get` and diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb new file mode 100644 index 00000000..d88b24be --- /dev/null +++ b/spec/support/database_cleaner.rb @@ -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