-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader_parser_test.rb
More file actions
77 lines (65 loc) · 2.19 KB
/
header_parser_test.rb
File metadata and controls
77 lines (65 loc) · 2.19 KB
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
require 'minitest/autorun'
require 'minitest/pride'
require './header_parser'
class HeaderParserTest < Minitest::Test
def test_it_places_h1_tags_around_chunks_with_one_hash
header = HeaderParser.new("# This is an h1 chunk.")
expected = "<h1>This is an h1 chunk.</h1>"
result = header.header_parser
assert_equal expected, result
end
def test_it_places_h2_tags_around_chunks_with_two_hashes
header = HeaderParser.new("## This is an h2 chunk.")
expected = "<h2>This is an h2 chunk.</h2>"
result = header.header_parser
assert_equal expected, result
end
def test_it_places_h3_tags_around_chunks_with_three_hashes
header = HeaderParser.new("### This is an h3 chunk.")
expected = "<h3>This is an h3 chunk.</h3>"
result = header.header_parser
assert_equal expected, result
end
def test_it_places_h4_tags_around_chunks_with_four_hashes
header = HeaderParser.new("#### This is an h4 chunk.")
expected = "<h4>This is an h4 chunk.</h4>"
result = header.header_parser
assert_equal expected, result
end
def test_correctly_recognizes_headers
header = HeaderParser.new("## This is a header chunk.")
expected = true
result = header.header?
assert_equal expected, result
end
def test_recognizes_what_is_not_a_header
header = HeaderParser.new("This is not a header chunk.")
expected = false
result = header.header?
assert_equal expected, result
end
def test_it_finds_the_first_space_after_hashes
header = HeaderParser.new("## This is an h2 chunk.")
expected = 2
result = header.first_space
assert_equal expected, result
end
def test_it_defines_the_text_start
header = HeaderParser.new("## This is an h2 chunk.")
expected = 3
result = header.text_start
assert_equal expected, result
end
def test_it_defines_the_text_body
header = HeaderParser.new("## This is an h2 chunk.")
expected = "This is an h2 chunk."
result = header.text_body
assert_equal expected, result
end
def test_it_gives_the_correct_header_number
header = HeaderParser.new("## This is an h2 chunk.")
expected = 2
result = header.header_number
assert_equal expected, result
end
end