1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/generators/plugin_test_helper.rb
yuuji.yaginuma e4e42d0b34 show relative path the rerun snippet of test runner in rails engine
Since the absolute path is not required to re-run the test,
modified so that unnecessary information is not displayed.

```ruby
# before
bin/rails test /path/to/blorgh/test/integration/navigation_test.rb:5

# after
bin/rails test test/integration/navigation_test.rb:5
```
2015-12-10 16:08:37 +09:00

24 lines
575 B
Ruby

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