require 'rspec'
require 'rspec/core/formatters/documentation_formatter'
require 'uninhibited/background_metadata'
require 'uninhibited/feature'
require 'uninhibited/formatter'
require 'uninhibited/object_extensions'
require 'uninhibited/version'

module Uninhibited

  # Set up Uninhibited's required features, and configures RSpec as necessary.
  def self.setup
    Object.send(:include, Uninhibited::ObjectExtensions)

    RSpec::Core::Metadata.send(:include, BackgroundMetadata)

    config = RSpec.configuration
    config.filter[:include_background] = true if config.filter
    config.formatter = Uninhibited::Formatter

    config.extend Uninhibited::Feature, :feature => true

    config.after(:each, :feature => true) do
      example.example_group.handle_exception(example)
    end
  end

end

Uninhibited.setup
