Sha256: e04daedee8d65ff403bdeb7ab202ee45e351e610bb3bee29dca0203faed5c27b

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require "rails/generators"
require "magic_test/engine"

module MagicTest
  class InstallGenerator < Rails::Generators::Base
    def self.source_paths
      [MagicTest::Engine.root, File.expand_path("../templates", __FILE__)]
    end

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

      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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
magic_test-0.0.9 lib/generators/magic_test/install_generator.rb
magic_test-0.0.7 lib/generators/magic_test/install_generator.rb
magic_test-0.0.6 lib/generators/magic_test/install_generator.rb
magic_test-0.0.5 lib/generators/magic_test/install_generator.rb