Class: MagicTest::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_pathsObject



6
7
8
# File 'lib/generators/magic_test/install_generator.rb', line 6

def self.source_paths
  [MagicTest::Engine.root, File.expand_path('../templates', __FILE__)]
end

Instance Method Details

#installObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/generators/magic_test/install_generator.rb', line 18

def install
  unless defined?(MagicTest)
    gem_group :test do
      gem 'magic_test'
    end
  end

  template 'config/initializers/magic_test.rb'

  generate 'system_test', 'basic'
  gsub_file 'test/system/basics_test.rb', '# ', ''
  gsub_file 'test/system/basics_test.rb', '#', ''
  gsub_file 'test/system/basics_test.rb', 'visiting the index', 'getting started'
  gsub_file 'test/system/basics_test.rb', 'visit basics_url', 'visit root_url'
  gsub_file 'test/system/basics_test.rb', 'assert_selector "h1", text: "Basic"', 'magic_test'

  gsub_file 'test/application_system_test_case.rb', 'using: :headless_chrome', "using: (ENV['SHOW_TESTS'] ? :chrome : :headless_chrome)"
  gsub_file 'test/application_system_test_case.rb', 'using: :headless_firefox', "using: (ENV['SHOW_TESTS'] ? :firefox : :headless_firefox)"


end

#jquery_already_includedObject

Override the attr_accessor generated by ‘argument’ so that subscription_owner_model is always returned lowercase.



14
15
16
# File 'lib/generators/magic_test/install_generator.rb', line 14

def jquery_already_included
  @jquery_already_included.strip.downcase.first == 'y'
end