forked from doubtfire-lms/doubtfire-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_helper.rb
60 lines (48 loc) · 1.53 KB
/
test_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'simplecov'
SimpleCov.start 'rails'
# Setup RAILS_ENV as test and expand config for test environment
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../../config/environment', __FILE__)
# Check if we're connected to the test DB
begin
ActiveRecord::Base.connection
rescue ActiveRecord::NoDatabaseError
# No database... try setting up
puts 'No test database has been setup! Setting first-time up...'
require 'rake'
Rake::Task['test:setup'].invoke
puts 'First-time test setup complete. Please re-run `rake test` again.'
exit
end
# Require minitest extensions
require 'minitest/rails'
require 'minitest/pride'
require 'minitest/around'
# Require all test helpers
require_all 'test/helpers'
require 'rails/test_help'
require 'database_cleaner'
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Silence deprecation warnings
ActiveSupport::Deprecation.silenced = true
# Support rollback of db changes after all tests
DatabaseCleaner.strategy = :transaction
def setup
DatabaseCleaner.start
end
def teardown
DatabaseCleaner.clean
end
# Add more helper methods to be used by all tests here...
require_all 'test/helpers'
extend MiniTest::Spec::DSL
register_spec_type self do |desc|
desc < ActiveRecord::Base if desc_is_a? Class
end
end