Skip to content

Commit

Permalink
Avoid duplication between PluginTestHelper and PluginHelpers, use onl…
Browse files Browse the repository at this point in the history
…y generate_plugin to generate plugins
  • Loading branch information
guilleiguaran committed Jun 4, 2023
1 parent 312e17e commit 61d4bf5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
11 changes: 0 additions & 11 deletions railties/test/generators/plugin_test_helper.rb
Expand Up @@ -23,15 +23,4 @@ def plugin_file(path, contents, mode: "w")
f.puts contents
end
end

def fill_in_gemspec_fields(gemspec_path = "#{plugin_path}/#{File.basename plugin_path}.gemspec")
# Some fields must be a valid URL.
filled_in = File.read(gemspec_path).gsub(/"TODO.*"/, "http://example.com".inspect)
File.write(gemspec_path, filled_in)
end

def resolve_rails_gem_to_repository(gemfile_path = "#{plugin_path}/Gemfile")
repository_path = File.expand_path("../../..", __dir__)
File.write(gemfile_path, "gem 'rails', path: #{repository_path.inspect}\n", mode: "a")
end
end
6 changes: 3 additions & 3 deletions railties/test/generators/plugin_test_runner_test.rb
Expand Up @@ -2,16 +2,16 @@

require "generators/plugin_test_helper"
require "env_helpers"
require "plugin_helpers"

class PluginTestRunnerTest < ActiveSupport::TestCase
include PluginTestHelper
include EnvHelpers
include PluginHelpers

def setup
@destination_root = Dir.mktmpdir("bukkits")
Dir.chdir(@destination_root) { `bundle exec rails plugin new bukkits --skip-bundle` }
fill_in_gemspec_fields
resolve_rails_gem_to_repository
generate_plugin("#{@destination_root}/bukkits")
plugin_file "test/dummy/db/schema.rb", ""
end

Expand Down
6 changes: 3 additions & 3 deletions railties/test/generators/test_runner_in_engine_test.rb
Expand Up @@ -2,16 +2,16 @@

require "generators/plugin_test_helper"
require "env_helpers"
require "plugin_helpers"

class TestRunnerInEngineTest < ActiveSupport::TestCase
include PluginTestHelper
include EnvHelpers
include PluginHelpers

def setup
@destination_root = Dir.mktmpdir("bukkits")
Dir.chdir(@destination_root) { `bundle exec rails plugin new bukkits --full --skip-bundle` }
fill_in_gemspec_fields
resolve_rails_gem_to_repository
generate_plugin("#{@destination_root}/bukkits", "--full")
plugin_file "test/dummy/db/schema.rb", ""
end

Expand Down

0 comments on commit 61d4bf5

Please sign in to comment.