# 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
if ENV["CODE_COVERAGE"] == "true"
  # SimpleCov must be started before anything else is loaded.
  require "simplecov"
  require "simplecov-json"

  SimpleCov.start do
    # Any not-loaded files matching this glob will be counted as having 0% coverage.
    track_files "lib/**/*.rb"

    # SimpleCov won't track coverage in files whose paths match these strings.
    add_filter [
      "/spec/",
      "/version.rb", # Loads in advance with `bundle exec`.
    ]

    formatter SimpleCov::Formatter::JSONFormatter
  end
end

require "#{File.dirname(__FILE__)}/../lib/nerve"

require 'factory_girl'

FactoryGirl.find_definitions

RSpec.configure do |config|
  config.run_all_when_everything_filtered = true
  config.filter_run :focus
  config.include RbConfig
  config.color = true

  # verify every double we can think of
  config.mock_with :rspec do |mocks|
    mocks.verify_doubled_constant_names = true
    mocks.verify_partial_doubles = true
  end

  # include factory-girl when running tests
  config.include FactoryGirl::Syntax::Methods

  # 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'
end
