Top Level Namespace
Defined Under Namespace
Modules: ActiveSupport, TestData
Instance Method Summary collapse
- #create_database_or_else_blow_up_if_its_not_empty! ⇒ Object
- #run_in_test_data_env(task_name) ⇒ Object
- #wrong_env? ⇒ Boolean
Instance Method Details
#create_database_or_else_blow_up_if_its_not_empty! ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/test_data/rake.rb', line 12 def create_database_or_else_blow_up_if_its_not_empty! raise unless Rails.env.test_data? unless TestData::DetectsDatabaseExistence.new.call Rake::Task["test_data:create_database"].invoke end unless TestData::DetectsDatabaseEmptiness.new.empty? raise TestData::Error.new("Database '#{TestData.config.database_name}' already exists and is not empty. To re-initialize it, drop it first (e.g. `rake test_data:drop_database`)") end end |
#run_in_test_data_env(task_name) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/test_data/rake.rb', line 5 def run_in_test_data_env(task_name) command = "RAILS_ENV=test_data #{Rails.root}/bin/rake #{task_name} --trace" unless system(command) fail "An error ocurred when running: #{command}" end end |
#wrong_env? ⇒ Boolean
1 2 3 |
# File 'lib/test_data/rake.rb', line 1 def wrong_env? Rails.env != "test_data" end |