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/test_runner_in_engine_test.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

31 lines
824 B
Ruby

require 'generators/plugin_test_helper'
class TestRunnerInEngineTest < ActiveSupport::TestCase
include PluginTestHelper
def setup
@destination_root = Dir.mktmpdir('bukkits')
Dir.chdir(@destination_root) { `bundle exec rails plugin new bukkits --full --skip-bundle` }
plugin_file 'test/dummy/db/schema.rb', ''
end
def teardown
FileUtils.rm_rf(@destination_root)
end
def test_rerun_snippet_is_relative_path
create_test_file 'post', pass: false
output = run_test_command('test/post_test.rb')
assert_match %r{Running:\n\nPostTest\nF\n\nwups!\n\nbin/rails test test/post_test.rb:6}, output
end
private
def plugin_path
"#{@destination_root}/bukkits"
end
def run_test_command(arguments)
Dir.chdir(plugin_path) { `bin/rails test #{arguments}` }
end
end