Skip to content

Commit

Permalink
tests: ensure log dir is created before running specs
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 5, 2018
1 parent 201eb33 commit f57184e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
23 changes: 7 additions & 16 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
require 'simplecov'
SimpleCov.start

ENV['RACK_ENV'] = 'test'
RACK_ENV = 'test'

$: << File.expand_path("../../", __FILE__)

require 'semantic_logger'
require 'pact_broker/logging/default_formatter'
SemanticLogger.add_appender(file_name: "log/test.log", formatter: PactBroker::Logging::DefaultFormatter.new)
RACK_ENV = ENV['RACK_ENV'] = 'test'

require 'db'
require 'tasks/database'
require 'pact_broker/db'
raise "Wrong environment!!! Don't run this script!! ENV['RACK_ENV'] is #{ENV['RACK_ENV']} and RACK_ENV is #{RACK_ENV}" if ENV['RACK_ENV'] != 'test' || RACK_ENV != 'test'
PactBroker::DB.connection = PactBroker::Database.database = DB::PACT_BROKER_DB
require 'simplecov'
SimpleCov.start

require 'support/logging'
require 'support/database'
require 'rack/test'
require 'pact_broker/api'
require 'rspec/its'
require 'rspec/pact/matchers'
require 'sucker_punch/testing/inline'
require 'webmock/rspec'

WebMock.disable_net_connect!(allow_localhost: true)

Dir.glob("./spec/support/**/*.rb") { |file| require file }

WebMock.disable_net_connect!(allow_localhost: true)

I18n.config.enforce_available_locales = false

RSpec.configure do | config |
Expand Down
5 changes: 5 additions & 0 deletions spec/support/database.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'db'
require 'tasks/database'
require 'pact_broker/db'
raise "Wrong environment!!! Don't run this script!! ENV['RACK_ENV'] is #{ENV['RACK_ENV']} and RACK_ENV is #{RACK_ENV}" if ENV['RACK_ENV'] != 'test' || RACK_ENV != 'test'
PactBroker::DB.connection = PactBroker::Database.database = DB::PACT_BROKER_DB
5 changes: 5 additions & 0 deletions spec/support/logging.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'semantic_logger'
require 'pact_broker/logging/default_formatter'

FileUtils.mkdir_p("log")
SemanticLogger.add_appender(file_name: "log/test.log", formatter: PactBroker::Logging::DefaultFormatter.new)

0 comments on commit f57184e

Please sign in to comment.