File: test_minitest_test_task.rb

package info (click to toggle)
ruby-minitest 6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 588 kB
  • sloc: ruby: 6,908; makefile: 7
file content (57 lines) | stat: -rw-r--r-- 1,320 bytes parent folder | download | duplicates (4)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require "minitest/autorun"

begin
  require "hoe"
rescue LoadError => e
  warn e.message
  return
end

require "minitest/test_task"

Hoe.load_plugins # make sure Hoe::Test is loaded

class TestHoeTest < Minitest::Test
  PATH = "test/minitest/test_minitest_test_task.rb"

  def util_cmd_string *prelude_framework
    mt_path = %w[lib test .].join File::PATH_SEPARATOR
    mt_expected = "-I%s -w -e '%srequire %p' -- "

    mt_expected % [mt_path, prelude_framework.join("; "), PATH]
  end

  def util_exp_cmd
    @tester.make_test_cmd.sub(/ -- .+/, " -- ")
  end

  def test_make_test_cmd_for_minitest
    skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]

    require "minitest/test_task"

    framework = %(require "minitest/autorun"; )

    @tester = Minitest::TestTask.create :test do |t|
      t.test_globs = [PATH]
    end

    assert_equal util_cmd_string(framework), util_exp_cmd
  end

  def test_make_test_cmd_for_minitest_prelude
    skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]

    require "minitest/test_task"

    prelude = %(require "other/file")
    framework = %(require "minitest/autorun"; )

    @tester = Minitest::TestTask.create :test do |t|
      t.test_prelude = prelude
      t.test_globs = [PATH]
    end

    assert_equal util_cmd_string(prelude, framework), util_exp_cmd
  end
end