Class: SuperDummyGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_new_pluginObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/super_test_engine/generate_dummy.rb', line 37

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_mailbox: true,
    skip_action_text: true,
    skip_action_cable: true,
    skip_coffee: true,
    database: "sqlite3",
  }

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

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

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

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

#delete_unnecessary_filesObject



69
70
71
72
73
74
75
76
# File 'lib/super_test_engine/generate_dummy.rb', line 69

def delete_unnecessary_files
  inside(dummy_path) do
    remove_file("app/assets/javascripts/cable.js")
    remove_file("app/channels/")
    remove_file("public/apple-touch-icon-precomposed.png")
    remove_file("public/apple-touch-icon.png")
  end
end