Class: SuperTestEngine::DummyGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/super_test_engine/dummy/dummy_generator.rb

Instance Method Summary collapse

Instance Method Details

#apply_required_changesObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/generators/super_test_engine/dummy/dummy_generator.rb', line 69

def apply_required_changes
  template("db_seeds.rb.tt", File.join(dummy_path, "db/seeds.rb"))

  insert_into_file(
    File.join(dummy_path, "config/application.rb"),
    %(require "super_test_engine"\n),
    before: "\nmodule Dummy\n"
  )

  inside(dummy_path) do
    invoke(Super::InstallGenerator, [], {})
    remove_file("app/controllers/admin/")
    remove_file("app/controllers/admin_controller.rb")
    remove_file("app/super/")
  end

  rake("db:create")
  rake("db:migrate")
end

#create_new_pluginObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/generators/super_test_engine/dummy/dummy_generator.rb', line 31

def create_new_plugin
  if plugin_name.blank?
    warn "Not currently in a plugin directory"
    exit
  end

  opts = {
    force: true,
    skip_active_storage: true,
    skip_action_mailer: true,
    skip_action_cable: true,
    skip_puma: true,
    skip_coffee: true,
    database: "sqlite3",
  }

  Dir.mktmpdir do |dir|
    plugin_path = File.join(dir, plugin_name)
    new_dummy_path = File.join(plugin_path, "test/dummy")

    invoke(Rails::Generators::PluginGenerator, [plugin_path], opts)

    inside(new_dummy_path) do
      remove_file(".ruby-version")
    end

    FileUtils.rm_rf(dummy_path)
    FileUtils.mv(new_dummy_path, dummy_path)
  end
end

#delete_unnecessary_filesObject



62
63
64
65
66
67
# File 'lib/generators/super_test_engine/dummy/dummy_generator.rb', line 62

def delete_unnecessary_files
  inside(dummy_path) do
    remove_file("app/assets/javascripts/cable.js")
    remove_file("app/channels/")
  end
end