File tree Expand file tree Collapse file tree 3 files changed +34
-12
lines changed
Expand file tree Collapse file tree 3 files changed +34
-12
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ module Bootstrap
3131 #
3232 # rubocop:disable Metrics/MethodLength
3333 def self . apply ( world , config )
34+ # TOOD: Have this behind a conditional.
3435 config = Rails . call ( world , config )
3536
3637 env = Env
Original file line number Diff line number Diff line change 11module Mutant
22 module Bootstrap
3- module Rails
4- def self . call ( world , config )
3+ class Rails
4+ include Procto . call , Concord . new ( :world , :config )
5+
6+ def call
57 world . stdout . puts ( 'Loading mutant config from rails environment' )
68
7- # TODO move to world.
9+ # TODO add env to world.
10+ #
11+ # Make actual env configurable
812 ENV [ 'RAILS_ENV' ] = 'test'
913
1014 world . kernel . require ( './config/environment.rb' )
1115
1216 ::Rails . application . eager_load!
1317
18+ # TODO: preload engines, these *love* to pack things
19+ # in the main project
20+ #
21+ # TODO: allow custom preload hooks.
22+
23+ add_rails_matchers
24+ end
25+
26+ private
27+
28+ def add_rails_matchers
29+ # This logic sucks, instead rails should be come a match expression
30+ # possibly allow match expressions like: `ActionController.subclasses`
31+ return config if config . matcher . match_expressions . any?
32+
33+ config . with (
34+ matcher : config . matcher . with ( match_expressions : rails_expressions )
35+ )
36+ end
37+
38+ def rails_expressions
1439 expressions = [
1540 ApplicationController ,
1641 *ApplicationController . subclasses ,
1742 ApplicationRecord ,
1843 *ApplicationRecord . subclasses
1944 ] . map { |klass | config . expression_parser . apply ( klass . name ) . from_right }
20-
21- config . with (
22- matcher : config . matcher . with (
23- match_expressions : config . matcher . match_expressions | expressions
24- )
25- )
2645 end
46+
2747 end # Rails
2848 end # Bootstrap
2949end # Mutant
Original file line number Diff line number Diff line change @@ -51,9 +51,10 @@ def add(attribute, value)
5151 # @return [Config]
5252 def merge ( other )
5353 self . class . new (
54- to_h
55- . map { |name , value | [ name , value + other . public_send ( name ) ] }
56- . to_h
54+ ignore_expressions : other . ignore_expressions + ignore_expressions ,
55+ match_expressions : other . match_expressions ,
56+ start_expressions : other . start_expressions ,
57+ subject_filters : other . subject_filters + subject_filters
5758 )
5859 end
5960
You can’t perform that action at this time.
0 commit comments