Skip to content

Commit

Permalink
add database cleaner for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
christinalcole committed Nov 6, 2017
1 parent 1973ab3 commit ad54b7f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 59 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ end
group :test do
gem 'faker'
gem 'capybara'
gem 'database_cleaner'
#gem 'launchy' # not likely to use save_and_open_page commands
end

Expand Down
118 changes: 59 additions & 59 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.5)
actionpack (= 5.0.5)
actioncable (5.0.6)
actionpack (= 5.0.6)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.5)
actionpack (= 5.0.5)
actionview (= 5.0.5)
activejob (= 5.0.5)
actionmailer (5.0.6)
actionpack (= 5.0.6)
actionview (= 5.0.6)
activejob (= 5.0.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.5)
actionview (= 5.0.5)
activesupport (= 5.0.5)
actionpack (5.0.6)
actionview (= 5.0.6)
activesupport (= 5.0.6)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.5)
activesupport (= 5.0.5)
actionview (5.0.6)
activesupport (= 5.0.6)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.5)
activesupport (= 5.0.5)
activejob (5.0.6)
activesupport (= 5.0.6)
globalid (>= 0.3.6)
activemodel (5.0.5)
activesupport (= 5.0.5)
activerecord (5.0.5)
activemodel (= 5.0.5)
activesupport (= 5.0.5)
activemodel (5.0.6)
activesupport (= 5.0.6)
activerecord (5.0.6)
activemodel (= 5.0.6)
activesupport (= 5.0.6)
arel (~> 7.0)
activesupport (5.0.5)
activesupport (5.0.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
Expand All @@ -45,15 +45,15 @@ GEM
bindex (0.5.0)
builder (3.2.3)
byebug (9.1.0)
capybara (2.15.1)
capybara (2.15.4)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
choice (0.2.0)
coderay (1.1.1)
coderay (1.1.2)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
Expand All @@ -62,6 +62,8 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
crass (1.0.2)
database_cleaner (1.6.2)
devise (4.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand All @@ -75,20 +77,21 @@ GEM
railties (>= 3.2, < 5.2)
erubis (2.7.0)
execjs (2.7.0)
factory_girl (4.8.0)
factory_girl (4.9.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0)
factory_girl_rails (4.9.0)
factory_girl (~> 4.9.0)
railties (>= 3.0.0)
faker (1.8.4)
i18n (~> 0.5)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
globalid (0.4.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashie (3.5.6)
i18n (0.8.6)
i18n (0.9.1)
concurrent-ruby (~> 1.0)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
Expand All @@ -100,30 +103,28 @@ GEM
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3)
loofah (2.1.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.6)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mail (2.7.0)
mini_mime (>= 0.1.1)
method_source (0.9.0)
mini_mime (0.1.4)
mini_portile2 (2.2.0)
mini_portile2 (2.3.0)
minitest (5.10.3)
multi_json (1.12.1)
multi_json (1.12.2)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.6.1)
omniauth (1.7.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
Expand All @@ -133,26 +134,25 @@ GEM
omniauth (~> 1.2)
orm_adapter (0.5.0)
pg (0.20.0)
pry (0.10.4)
pry (0.11.2)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
method_source (~> 0.9.0)
public_suffix (3.0.0)
puma (3.10.0)
rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.5)
actioncable (= 5.0.5)
actionmailer (= 5.0.5)
actionpack (= 5.0.5)
actionview (= 5.0.5)
activejob (= 5.0.5)
activemodel (= 5.0.5)
activerecord (= 5.0.5)
activesupport (= 5.0.5)
rails (5.0.6)
actioncable (= 5.0.6)
actionmailer (= 5.0.6)
actionpack (= 5.0.6)
actionview (= 5.0.6)
activejob (= 5.0.6)
activemodel (= 5.0.6)
activerecord (= 5.0.6)
activesupport (= 5.0.6)
bundler (>= 1.3.0)
railties (= 5.0.5)
railties (= 5.0.6)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand All @@ -164,13 +164,13 @@ GEM
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.5)
actionpack (= 5.0.5)
activesupport (= 5.0.5)
railties (5.0.6)
actionpack (= 5.0.6)
activesupport (= 5.0.6)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rake (12.2.1)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
Expand All @@ -195,7 +195,7 @@ GEM
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
ruby-graphviz (1.2.3)
sass (3.5.1)
sass (3.5.3)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand All @@ -206,7 +206,6 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
slop (3.6.0)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
Expand All @@ -215,7 +214,7 @@ GEM
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
Expand All @@ -226,7 +225,7 @@ GEM
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.3)
tzinfo (1.2.3)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
Expand All @@ -250,6 +249,7 @@ DEPENDENCIES
byebug
capybara
coffee-rails (~> 4.2)
database_cleaner
devise
dotenv-rails
factory_girl_rails
Expand Down
14 changes: 14 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@
# support for factory_girl_rails
config.include FactoryGirl::Syntax::Methods

# support for database_cleaner
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end

config.before(:each) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.start
end

config.after(:each) do
DatabaseCleaner.clean
end

#support for Devise
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::ControllerHelpers, type: :view
Expand Down

0 comments on commit ad54b7f

Please sign in to comment.