Sha256: 90409a47833f7b1061dbf8bbaf6c511abae7bbfb25aeb3cc36b5ebe0eadeb4be

Contents?: true

Size: 1.86 KB

Versions: 4

Compression:

Stored size: 1.86 KB

Contents

ENV['RUBY_ENV'] ||= 'test'
ENV['MOTHERBRAIN_PATH'] ||= File.join(File.expand_path(File.dirname(__FILE__)), "tmp/.mb")
ENV['BERKSHELF_PATH'] ||= File.join(File.expand_path(File.dirname(__FILE__)), "tmp/.berkshelf")
ENV['CHEF_API_URL'] = 'http://localhost:28890'

require 'rubygems'
require 'bundler'
require 'rspec'
require 'json_spec'
require 'webmock/rspec'
require 'rack/test'
require 'motherbrain'
require 'chef_zero/server'

def setup_rspec
  Dir[File.join(File.expand_path("../../spec/support/**/*.rb", __FILE__))].each { |f| require f }

  RSpec.configure do |config|
    config.include JsonSpec::Helpers
    config.include MotherBrain::RSpec::Doubles
    config.include MotherBrain::Matchers
    config.include MotherBrain::SpecHelpers
    config.include MotherBrain::RSpec::Berkshelf
    config.include MotherBrain::RSpec::ChefServer
    config.include MotherBrain::Mixin::Services

    config.mock_with :rspec
    config.treat_symbols_as_metadata_keys_with_true_values = true
    config.filter_run focus: true
    config.run_all_when_everything_filtered = true

    config.before(:suite) do
      WebMock.disable_net_connect!(allow_localhost: true, net_http_connect_on_start: true)
      MB::RSpec::ChefServer.start
    end

    config.before(:all) do
      Celluloid.shutdown
      @config = generate_valid_config
      @app    = MB::Application.run!(@config)
      MB::Logging.setup(location: '/dev/null')
    end

    config.before(:each) do
      clean_tmp_path
      MB::RSpec::ChefServer.server.clear_data
    end
  end
end

if jruby?
  setup_rspec
else
  require 'spork'

  Spork.prefork do
    setup_rspec
  end

  Spork.each_run do
    require 'motherbrain'

    # Required to ensure Celluloid boots properly on each run
    Celluloid::Notifications::Fanout.supervise_as :notifications_fanout
    Celluloid::IncidentReporter.supervise_as :default_incident_reporter, STDERR
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
motherbrain-0.14.4 spec/spec_helper.rb
motherbrain-0.14.3 spec/spec_helper.rb
motherbrain-0.14.2 spec/spec_helper.rb
motherbrain-0.13.1 spec/spec_helper.rb