spec/spec_helper.rb in cryptocoin_payable-1.4.0 vs spec/spec_helper.rb in cryptocoin_payable-1.4.1

- old
+ new

@@ -10,10 +10,26 @@ config.cassette_library_dir = 'spec/fixtures/vcr_cassettes' config.hook_into :webmock config.configure_rspec_metadata! end +def create_tables + ENV['RAILS_ENV'] = 'test' + load 'spec/dummy/db/schema.rb' +end + +def drop_tables + %i[ + coin_payment_transactions + coin_payments + currency_conversions + widgets + ].each do |table_name| + ActiveRecord::Base.connection.drop_table(table_name) + end +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`. # The generated `.rspec` file contains `--require spec_helper` which will cause # this file to always be loaded, without a need to explicitly require it in any # files. @@ -59,9 +75,16 @@ config.shared_context_metadata_behavior = :apply_to_host_groups config.before(:suite) do CryptocoinPayable.configure do end + + ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'cryptocoin_payable_test') + create_tables + end + + config.after(:suite) do + drop_tables end config.include RSpec::Benchmark::Matchers # The settings below are suggested to provide a good initial experience