module RSpec::Ui

Constants

DIRECTORY_MAPPINGS

Mappings used by ‘infer_spec_type_from_file_location!`.

@api private

Public Class Methods

initialize_configuration(config) click to toggle source

@private

# File lib/rspec/ui/configuration.rb, line 32
def self.initialize_configuration(config)

  config.add_setting :always_run_ui_tests, :default => false

  # Borrowed from rspec-rails
  config.instance_exec do
    def infer_spec_type_from_file_location!
      DIRECTORY_MAPPINGS.each do |type, dir_parts|
        escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]')
        define_derived_metadata(:file_path => escaped_path) do |metadata|
          metadata[:type] ||= type
        end
      end
    end
  end

  config.include RSpec::Ui::UiExampleGroup, :type => :ui
end

Public Instance Methods

infer_spec_type_from_file_location!() click to toggle source
# File lib/rspec/ui/configuration.rb, line 38
def infer_spec_type_from_file_location!
  DIRECTORY_MAPPINGS.each do |type, dir_parts|
    escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]')
    define_derived_metadata(:file_path => escaped_path) do |metadata|
      metadata[:type] ||= type
    end
  end
end