Skip to content

Commit

Permalink
Always clean up database before running each test.
Browse files Browse the repository at this point in the history
  • Loading branch information
steverandy committed Sep 29, 2011
1 parent c54e4e0 commit 7f7cfc4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 12 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Expand Up @@ -20,5 +20,4 @@ gem "domainatrix", "~> 0.0.10"
gem "capybara", ">= 0.4.0" gem "capybara", ">= 0.4.0"
gem "fabrication", "1.1.0" gem "fabrication", "1.1.0"
gem "database_cleaner", "0.6.0" gem "database_cleaner", "0.6.0"
gem "ansi" gem "minitest", "~> 2.6.1"
gem "turn"
7 changes: 2 additions & 5 deletions Gemfile.lock
Expand Up @@ -31,7 +31,6 @@ GEM
activesupport (3.1.0) activesupport (3.1.0)
multi_json (~> 1.0) multi_json (~> 1.0)
addressable (2.2.6) addressable (2.2.6)
ansi (1.2.5)
arel (2.2.1) arel (2.2.1)
bcrypt-ruby (3.0.0) bcrypt-ruby (3.0.0)
bson (1.3.1) bson (1.3.1)
Expand Down Expand Up @@ -68,6 +67,7 @@ GEM
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
mime-types (1.16) mime-types (1.16)
minitest (2.6.1)
mongo (1.3.1) mongo (1.3.1)
bson (>= 1.3.1) bson (>= 1.3.1)
mongo-rails-instrumentation (0.2.4) mongo-rails-instrumentation (0.2.4)
Expand Down Expand Up @@ -130,8 +130,6 @@ GEM
treetop (1.4.10) treetop (1.4.10)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
turn (0.8.2)
ansi (>= 1.2.2)
tzinfo (0.3.29) tzinfo (0.3.29)
xpath (0.1.4) xpath (0.1.4)
nokogiri (~> 1.3) nokogiri (~> 1.3)
Expand All @@ -140,7 +138,6 @@ PLATFORMS
ruby ruby


DEPENDENCIES DEPENDENCIES
ansi
bcrypt-ruby (~> 3.0.0) bcrypt-ruby (~> 3.0.0)
bson_ext (~> 1.3.1) bson_ext (~> 1.3.1)
capybara (>= 0.4.0) capybara (>= 0.4.0)
Expand All @@ -151,11 +148,11 @@ DEPENDENCIES
fabrication (= 1.1.0) fabrication (= 1.1.0)
haml (~> 3.1.0) haml (~> 3.1.0)
mime-types (~> 1.16) mime-types (~> 1.16)
minitest (~> 2.6.1)
mongo-rails-instrumentation (~> 0.2.4) mongo-rails-instrumentation (~> 0.2.4)
mongoid (~> 2.2.1) mongoid (~> 2.2.1)
mustache (~> 0.99.4) mustache (~> 0.99.4)
rack-gridfs (~> 0.4.1) rack-gridfs (~> 0.4.1)
rails (>= 3.1.0) rails (>= 3.1.0)
redcarpet (= 2.0.0b5) redcarpet (= 2.0.0b5)
sass-rails (~> 3.1.0) sass-rails (~> 3.1.0)
turn
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -7,13 +7,13 @@ rescue LoadError
end end


require "rake" require "rake"
require "rake/rdoctask" require "rdoc/task"
require "rake/testtask" require "rake/testtask"


Rake::TestTask.new(:test) do |t| Rake::TestTask.new(:test) do |t|
t.libs << "lib" t.libs << "lib"
t.libs << "test" t.libs << "test"
t.pattern = "test/**/*_test.rb" t.test_files = Dir.glob("test/**/*_test.rb")
t.verbose = false t.verbose = false
end end


Expand Down
2 changes: 0 additions & 2 deletions test/test_helper.rb
Expand Up @@ -5,7 +5,6 @@
require File.expand_path("../fabricators.rb", __FILE__) require File.expand_path("../fabricators.rb", __FILE__)
require "rails/test_help" require "rails/test_help"
require "database_cleaner" require "database_cleaner"
require "turn"


ActionMailer::Base.delivery_method = :test ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true ActionMailer::Base.perform_deliveries = true
Expand All @@ -23,5 +22,4 @@


# Clean database. # Clean database.
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :truncation
DatabaseCleaner.start
DatabaseCleaner.clean DatabaseCleaner.clean
4 changes: 4 additions & 0 deletions test/unit/concen_test.rb
Expand Up @@ -3,6 +3,10 @@
require "minitest/autorun" require "minitest/autorun"


describe Concen do describe Concen do
before do
DatabaseCleaner.clean
end

it "must be a Module" do it "must be a Module" do
Concen.must_be_kind_of Module Concen.must_be_kind_of Module
end end
Expand Down
4 changes: 4 additions & 0 deletions test/unit/grid_file_test.rb
Expand Up @@ -3,6 +3,10 @@
require "minitest/autorun" require "minitest/autorun"


describe Concen::GridFile do describe Concen::GridFile do
before do
DatabaseCleaner.clean
end

it "can store file in GridFS" do it "can store file in GridFS" do
page = Fabricate "concen/page" page = Fabricate "concen/page"
grid_file = page.grid_files.build grid_file = page.grid_files.build
Expand Down
2 changes: 1 addition & 1 deletion test/unit/page_test.rb
Expand Up @@ -3,7 +3,7 @@
require "minitest/autorun" require "minitest/autorun"


describe Concen::Page do describe Concen::Page do
def setup before do
DatabaseCleaner.clean DatabaseCleaner.clean
end end


Expand Down
4 changes: 4 additions & 0 deletions test/unit/user_test.rb
Expand Up @@ -3,6 +3,10 @@
require "minitest/autorun" require "minitest/autorun"


describe Concen::User do describe Concen::User do
before do
DatabaseCleaner.clean
end

it "can create user" do it "can create user" do
user = Fabricate "concen/user" user = Fabricate "concen/user"
user.id.wont_be_nil user.id.wont_be_nil
Expand Down

0 comments on commit 7f7cfc4

Please sign in to comment.