5
5
location = {"line" : 1 , "column" : 1 }
6
6
7
7
8
- def test_it_matches_FeatureLine ():
9
- tm = GherkinInMarkdownTokenMatcher ("en" )
10
- line = GherkinLine ("""## Feature: hello""" , location ["line" ])
8
+ def test_it_matches_FeatureLineH1 ():
9
+ tm = GherkinInMarkdownTokenMatcher ('en' )
10
+ line = GherkinLine ('''# Feature: hello''' ,location ['line' ])
11
+ token = Token (gherkin_line = line , location = location )
12
+ assert tm .match_FeatureLine (token )
13
+ assert token .matched_type == 'FeatureLine'
14
+ assert token .matched_keyword == 'Feature'
15
+ assert token .matched_text == 'hello'
16
+
17
+ def test_it_matches_FeatureLineH2 ():
18
+ tm = GherkinInMarkdownTokenMatcher ('en' )
19
+ line = GherkinLine ('''## Feature: hello''' ,location ['line' ])
11
20
token = Token (gherkin_line = line , location = location )
12
21
assert tm .match_FeatureLine (token )
13
22
assert token .matched_type == "FeatureLine"
@@ -25,6 +34,15 @@ def test_it_matches_FeatureLine_in_French():
25
34
assert token .matched_text == "hello"
26
35
27
36
37
+ def test_it_matches_FeatureLine_without_the_Feature_keyword ():
38
+ tm = GherkinInMarkdownTokenMatcher ('en' )
39
+ line = GherkinLine ('''# hello''' ,location ['line' ])
40
+ token = Token (gherkin_line = line , location = location )
41
+ assert tm .match_FeatureLine (token )
42
+ assert token .matched_type == 'FeatureLine'
43
+ assert token .matched_keyword == None
44
+ assert token .matched_text == '# hello'
45
+
28
46
def test_it_matches_bullet_Step ():
29
47
tm = GherkinInMarkdownTokenMatcher ("en" )
30
48
line = GherkinLine (""" * Given I have 3 cukes""" , location ["line" ])
@@ -41,21 +59,33 @@ def test_it_matches_plus_Step():
41
59
line = GherkinLine (""" + Given I have 3 cukes""" , location ["line" ])
42
60
token = Token (gherkin_line = line , location = location )
43
61
assert tm .match_StepLine (token )
44
- assert token .matched_type == " StepLine"
45
- assert token .matched_keyword == " Given "
46
- assert token .matched_text == "I have 3 cukes"
47
- assert token .location [ "column" ] == 6
48
-
62
+ assert token .matched_type == ' StepLine'
63
+ assert token .matched_keyword == ' Given '
64
+ assert token .matched_keyword_type == 'Context'
65
+ assert token .matched_text == 'I have 3 cukes'
66
+ assert token . location [ 'column' ] == 6
49
67
50
68
def test_it_matches_hyphen_Step ():
51
69
tm = GherkinInMarkdownTokenMatcher ("en" )
52
70
line = GherkinLine (""" - Given I have 3 cukes""" , location ["line" ])
53
71
token = Token (gherkin_line = line , location = location )
54
72
assert tm .match_StepLine (token )
55
- assert token .matched_type == "StepLine"
56
- assert token .matched_keyword == "Given "
57
- assert token .matched_text == "I have 3 cukes"
58
- assert token .location ["column" ] == 6
73
+ assert token .matched_type == 'StepLine'
74
+ assert token .matched_keyword == 'Given '
75
+ assert token .matched_keyword_type == 'Context'
76
+ assert token .matched_text == 'I have 3 cukes'
77
+ assert token .location ['column' ] == 6
78
+
79
+ def test_it_matches_a_when_Step ():
80
+ tm = GherkinInMarkdownTokenMatcher ('en' )
81
+ line = GherkinLine (''' - When I do something''' ,location ['line' ])
82
+ token = Token (gherkin_line = line , location = location )
83
+ assert tm .match_StepLine (token )
84
+ assert token .matched_type == 'StepLine'
85
+ assert token .matched_keyword == 'When '
86
+ assert token .matched_keyword_type == 'Action'
87
+ assert token .matched_text == 'I do something'
88
+ assert token .location ['column' ] == 6
59
89
60
90
61
91
def test_it_matches_arbitrary_text_as_Other ():
@@ -156,19 +186,6 @@ def test_it_does_not_match_table_row_indented_6_space():
156
186
assert not tm .match_TableRow (token )
157
187
158
188
159
- def test_it_matches_table_separator_row_as_comment ():
160
- tm = GherkinInMarkdownTokenMatcher ("en" )
161
-
162
- l1 = GherkinLine (" | h1 | h2 |" , location ["line" ])
163
- t1 = Token (l1 , location )
164
- assert tm .match_TableRow (t1 )
165
-
166
- l2 = GherkinLine (" | --- | --- |" , location ["line" ])
167
- t2 = Token (l2 , location )
168
- assert not tm .match_TableRow (t2 )
169
- assert tm .match_Comment (t2 )
170
-
171
-
172
189
def test_it_matches_indented_tags ():
173
190
tm = GherkinInMarkdownTokenMatcher ("en" )
174
191
@@ -238,6 +255,34 @@ def test_it_matches_ExamplesLine():
238
255
line = GherkinLine ("""## Examples: """ , location ["line" ])
239
256
token = Token (gherkin_line = line , location = location )
240
257
assert tm .match_ExamplesLine (token )
241
- assert token .matched_type == "ExamplesLine"
242
- assert token .matched_keyword == "Examples"
243
- assert token .matched_text == ""
258
+ assert token .matched_type == 'ExamplesLine'
259
+ assert token .matched_keyword == 'Examples'
260
+ assert token .matched_text == ''
261
+
262
+ def test_it_matches_Empty ():
263
+ tm = GherkinInMarkdownTokenMatcher ('en' )
264
+ line = GherkinLine ('''''' ,location ['line' ])
265
+ token = Token (gherkin_line = line , location = location )
266
+ assert tm .match_Empty (token )
267
+ assert token .matched_type == 'Empty'
268
+ assert token .matched_keyword == None
269
+ assert token .matched_text == None
270
+
271
+ def test_it_matches_arbitrary_text_as_Empty_after_the_FeatureLine_has_already_been_matched ():
272
+ # White Box testing - implementation detail...
273
+ # Given the FeatureLine has already been matched
274
+ tm = GherkinInMarkdownTokenMatcher ('en' )
275
+
276
+ line = GherkinLine ('''# something arbitrary''' ,location ['line' ])
277
+ token = Token (gherkin_line = line , location = location )
278
+ assert (tm .match_FeatureLine (token ))
279
+
280
+ line = GherkinLine ('''arbitrary text''' ,location ['line' ])
281
+ token = Token (gherkin_line = line , location = location )
282
+
283
+ assert (tm .match_Empty (token ))
284
+ assert token .matched_type == 'Empty'
285
+ assert token .matched_items == []
286
+ assert token .matched_keyword == None
287
+ assert token .matched_text == None
288
+ pass
0 commit comments