-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathextract_metadata_test.rb
79 lines (71 loc) · 2.32 KB
/
extract_metadata_test.rb
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require "test_helper"
require 'test_runner'
class ExtractMetadataTest < Minitest::Test
def test_assert_equal
expected = [{
test: "test_assert_equal_works_properly",
name: "Assert equal works properly",
test_code: %(some_result = TwoFer.two_fer\nassert_equal "One for you, one for me.", some_result),
index: 0,
task_id: 123
}]
actual = TestRunner::ExtractMetadata.(File.expand_path("fixtures/metadata/assert_equal.rb", __dir__))
assert_equal expected, actual
end
def test_no_skips
expected = [{
test: "test_skip_works_properly",
name: "Skip works properly",
test_code: "something = \"Something\"\nassert something.present?",
index: 0,
task_id: 456
}]
actual = TestRunner::ExtractMetadata.(File.expand_path("fixtures/metadata/skip.rb", __dir__))
assert_equal expected, actual
end
def test_no_skip_comments
expected = [{
test: "test_skip_works_properly",
name: "Skip works properly",
test_code: "something = \"Something\"\nassert something.present?",
index: 0,
task_id: 789
}]
actual = TestRunner::ExtractMetadata.(File.expand_path("fixtures/metadata/skip_comment.rb", __dir__))
assert_equal expected, actual
end
def test_extracting_indices
expected = [
{
test: "test_zebra",
name: "Zebra",
test_code: %(some_result = TwoFer.two_fer("zebra")\nassert_equal "One for you, one for zebra.", some_result),
index: 0,
task_id: 789
},
{
test: "test_anaconda",
name: "Anaconda",
test_code: %(some_result = TwoFer.two_fer("anaconda")\nassert_equal "One for you, one for anaconda.", some_result),
index: 1,
task_id: nil
},
{
test: "test_gorilla",
name: "Gorilla",
test_code: %(some_result = TwoFer.two_fer("gorilla")\nassert_equal "One for you, one for gorilla.", some_result),
index: 2,
task_id: nil
},
{
test: "test_boa",
name: "Boa",
test_code: %(some_result = TwoFer.two_fer("boa")\nassert_equal "One for you, one for boa.", some_result),
index: 3,
task_id: nil
}
]
actual = TestRunner::ExtractMetadata.(File.expand_path("fixtures/metadata/indices.rb", __dir__))
assert_equal expected, actual
end
end