diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-12-10 08:40:23 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-12-10 08:40:23 +0100 |
commit | 3e5a1c2865f78236d4bc2e807b496267b99d8575 (patch) | |
tree | 66e99342a40795b2e5fd9a94b56ab44f549f2789 /railties/test/generators/plugin_test_helper.rb | |
parent | 11fbcf84ac29d6040be1b0988d22054342ed74d4 (diff) | |
parent | e4e42d0b346065f1fce6caaea669c3e4bc42dfc8 (diff) | |
download | rails-3e5a1c2865f78236d4bc2e807b496267b99d8575.tar.gz rails-3e5a1c2865f78236d4bc2e807b496267b99d8575.tar.bz2 rails-3e5a1c2865f78236d4bc2e807b496267b99d8575.zip |
Merge pull request #22546 from y-yagi/show_relative_path_in_test_runner
show relative path the rerun snippet of test runner in rails engine
Diffstat (limited to 'railties/test/generators/plugin_test_helper.rb')
-rw-r--r-- | railties/test/generators/plugin_test_helper.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/railties/test/generators/plugin_test_helper.rb b/railties/test/generators/plugin_test_helper.rb new file mode 100644 index 0000000000..96c1b1d31f --- /dev/null +++ b/railties/test/generators/plugin_test_helper.rb @@ -0,0 +1,24 @@ +require 'abstract_unit' +require 'tmpdir' + +module PluginTestHelper + def create_test_file(name, pass: true) + plugin_file "test/#{name}_test.rb", <<-RUBY + require 'test_helper' + + class #{name.camelize}Test < ActiveSupport::TestCase + def test_truth + puts "#{name.camelize}Test" + assert #{pass}, 'wups!' + end + end + RUBY + end + + def plugin_file(path, contents, mode: 'w') + FileUtils.mkdir_p File.dirname("#{plugin_path}/#{path}") + File.open("#{plugin_path}/#{path}", mode) do |f| + f.puts contents + end + end +end |