-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemphasis_parser_test.rb
More file actions
42 lines (35 loc) · 1.44 KB
/
emphasis_parser_test.rb
File metadata and controls
42 lines (35 loc) · 1.44 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
require 'minitest/autorun'
require 'minitest/pride'
require './emphasis_parser'
class EmphasisParserTest < Minitest::Test
def test_it_replaces_one_asterisk_with_em_tags
emphasis = EmphasisParser.new("This *chunk* has two *emphasis* <strong>tags</strong>.")
expected = "This <em>chunk</em> has two <em>emphasis</em> <strong>tags</strong>."
result = emphasis.emphasis_parser
assert_equal expected, result
end
def test_correctly_recognizes_emphasized_text
emphasis = EmphasisParser.new("This *chunk* has two *emphasis* <strong>tags</strong>.")
expected = true
result = emphasis.emphasis?
assert_equal expected, result
end
def test_recognizes_non_emphasized_text
emphasis = EmphasisParser.new("This chunk has no emphasis <strong>tags</strong>.")
expected = false
result = emphasis.emphasis?
assert_equal expected, result
end
def test_it_correctly_labels_open_tags
emphasis = EmphasisParser.new("This *chunk* has two *emphasis* <strong>tags</strong>.")
expected = "This <em>chunk* has two *emphasis* <strong>tags</strong>."
result = emphasis.emphasis_open
assert_equal expected, result
end
def test_it_correctly_labels_closed_tags
emphasis = EmphasisParser.new("This <em>chunk* has two *emphasis* <strong>tags</strong>.")
expected = "This <em>chunk</em> has two *emphasis* <strong>tags</strong>."
result = emphasis.emphasis_close
assert_equal expected, result
end
end