Sha256: 6236da9869e9b3fd7acde3405adbf6a87d440ef0f978075d0000c2c353c278d3

Contents?: true

Size: 1.95 KB

Versions: 6

Compression:

Stored size: 1.95 KB

Contents

require 'rubygems'
require 'bundler'
require 'logger'

Bundler.setup

require 'active_record'
require 'database_cleaner'
require 'usda-nutrient-database'
require 'shoulda-matchers'
require 'webmock/rspec'

UsdaNutrientDatabase.configure do |config|
  config.perform_logging = false
end

# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
  config.run_all_when_everything_filtered = true
  config.filter_run :focus

  # Run specs in random order to surface order dependencies. If you find an
  # order dependency and want to debug it, you can fix the order by providing
  # the seed, which is printed after each run.
  #     --seed 1234
  config.order = 'random'

  config.fail_fast = true

  db_name = ENV['DB'] || 'postgresql'
  database_yml = File.expand_path('../database.yml', __FILE__)
  ActiveRecord::Base.configurations = YAML.load_file(database_yml)
  db_config = ActiveRecord::Base.configurations[db_name]

  begin
    ActiveRecord::Base.establish_connection(db_name)
    ActiveRecord::Base.connection
  rescue PG::ConnectionBad
    ActiveRecord::Base.establish_connection db_config.merge('database' => nil)
    ActiveRecord::Base.connection.create_database db_config['database']
    ActiveRecord::Base.establish_connection db_config
  end

  ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'debug.log'))
  ActiveRecord::Base.default_timezone = :utc

  ActiveRecord::Migration.verbose = false
  load(File.join(File.dirname(__FILE__), 'schema.rb'))

  config.before :suite do
    DatabaseCleaner.strategy = :transaction
    DatabaseCleaner.clean_with(:truncation)
  end

  config.before do
    DatabaseCleaner.start
  end

  config.after do
    DatabaseCleaner.clean
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
usda-nutrient-database-1.0.0 spec/spec_helper.rb
usda-nutrient-database-0.8.1 spec/spec_helper.rb
usda-nutrient-database-0.8.0 spec/spec_helper.rb
usda-nutrient-database-0.7.0 spec/spec_helper.rb
usda-nutrient-database-0.6.0 spec/spec_helper.rb
usda-nutrient-database-0.5.0 spec/spec_helper.rb