Class: Mutante::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/mutante/configuration.rb

Constant Summary collapse

DEFAULT_RAILS_GLOBS =
%w[
  app/models/**/*.rb
  app/controllers/**/*.rb
  app/services/**/*.rb
  app/jobs/**/*.rb
  app/mailers/**/*.rb
  app/helpers/**/*.rb
  app/channels/**/*.rb
  app/serializers/**/*.rb
  lib/**/*.rb
].freeze
DEFAULT_EXCLUDE_GLOBS =
%w[
  spec/**/*
  test/**/*
  config/**/*
  db/**/*
  vendor/**/*
  tmp/**/*
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



30
31
32
33
34
35
36
# File 'lib/mutante/configuration.rb', line 30

def initialize
  @include_globs  = DEFAULT_RAILS_GLOBS.dup
  @exclude_globs  = DEFAULT_EXCLUDE_GLOBS.dup
  @test_command   = default_test_command
  @test_mappings  = {}
  @root           = Dir.pwd
end

Instance Attribute Details

#exclude_globsObject

Returns the value of attribute exclude_globs.



24
25
26
# File 'lib/mutante/configuration.rb', line 24

def exclude_globs
  @exclude_globs
end

#include_globsObject

Returns the value of attribute include_globs.



24
25
26
# File 'lib/mutante/configuration.rb', line 24

def include_globs
  @include_globs
end

#rootObject

Returns the value of attribute root.



24
25
26
# File 'lib/mutante/configuration.rb', line 24

def root
  @root
end

#test_commandObject

Returns the value of attribute test_command.



24
25
26
# File 'lib/mutante/configuration.rb', line 24

def test_command
  @test_command
end

#test_mappingsObject

Returns the value of attribute test_mappings.



24
25
26
# File 'lib/mutante/configuration.rb', line 24

def test_mappings
  @test_mappings
end

Instance Method Details

#map(source_glob, to:) ⇒ Object

Map a source-file glob to the spec file(s) that cover it.

config.map "app/services/**/*.rb", to: "spec/services/{basename}_spec.rb"

Placeholders in the target:

{basename}     - file name without extension
{relative}     - path relative to app/ or lib/
{relative_dir} - directory part of {relative}


46
47
48
# File 'lib/mutante/configuration.rb', line 46

def map(source_glob, to:)
  test_mappings[source_glob] = to
end