Sha256: 352dd014191b675856f4e74f74ce03a866490723ab701c60298c221ffca7dbc1

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 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

    argument :jquery_already_included, :type => :string, :default => 'yes'

    # Override the attr_accessor generated by 'argument' so that
    # subscription_owner_model is always returned lowercase.
    def jquery_already_included
      @jquery_already_included.strip.downcase.first == 'y'
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
magic_test-0.0.4 lib/generators/magic_test/install_generator.rb
magic_test-0.0.3 lib/generators/magic_test/install_generator.rb
magic_test-0.0.2 lib/generators/magic_test/install_generator.rb
magic_test-0.0.1 lib/generators/magic_test/install_generator.rb