Skip to content

Commit

Permalink
Load plugin VERSION constant by default
Browse files Browse the repository at this point in the history
For example, for a plugin like `my_plugin`, this makes the
`MyPlugin::VERSION` constant available to all consumers by default.

This commit also replaces the default generated test with a test that
the developer is less likely to delete.
  • Loading branch information
jonathanhefner committed Jul 31, 2020
1 parent 6b359ce commit f243470
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
@@ -1,3 +1,4 @@
require "<%= namespaced_name %>/version"
<% if engine? -%>
require "<%= namespaced_name %>/engine"
<% else -%>
Expand Down
@@ -1,7 +1,7 @@
require "test_helper"

class <%= camelized_modules %>Test < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, <%= camelized_modules %>
test "it has a version number" do
assert <%= camelized_modules %>::VERSION
end
end
7 changes: 5 additions & 2 deletions railties/test/generators/plugin_generator_test.rb
Expand Up @@ -75,10 +75,13 @@ def test_generating_without_options
assert_match(/Rails::TestUnitReporter\.executable = 'bin\/test'/, content)
end
assert_file "lib/bukkits/railtie.rb", /module Bukkits\n class Railtie < ::Rails::Railtie\n end\nend/
assert_file "lib/bukkits.rb", /require "bukkits\/railtie"/
assert_file "lib/bukkits.rb" do |content|
assert_match(/require "bukkits\/version"/, content)
assert_match(/require "bukkits\/railtie"/, content)
end
assert_file "test/bukkits_test.rb" do |content|
assert_match(/class BukkitsTest < ActiveSupport::TestCase/, content)
assert_match(/assert_kind_of Module, Bukkits/, content)
assert_match(/assert Bukkits::VERSION/, content)
end
assert_file "bin/test"
assert_no_file "bin/rails"
Expand Down

0 comments on commit f243470

Please sign in to comment.