aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/test_runner_in_engine_test.rb
blob: 641c5d0835f4c64fca1c9905ebc07be0acccd886 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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