Class: TestData::WebpackerYamlGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/test_data/webpacker_yaml_generator.rb

Constant Summary collapse

AFTER_DEVELOPMENT_WEBPACK_STANZA_REGEX =
/^development:/

Instance Method Summary collapse

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/test_data/webpacker_yaml_generator.rb', line 8

def call
  if Configurators::WebpackerYaml.new.verify.looks_good?
    TestData.log.debug "'test_data' section not needed in config/webpacker.yml"
  else
    inject_into_file "config/webpacker.yml", after: AFTER_DEVELOPMENT_WEBPACK_STANZA_REGEX do
      " &development"
    end
    inject_into_file "config/webpacker.yml", before: BEFORE_TEST_STANZA_REGEX do
      "\n        # Used in conjunction with the test_data gem\n        test_data:\n          <<: *development\n\n      YAML\n    end\n  end\nend\n"