55location = {"line" : 1 , "column" : 1 }
66
77
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' ])
1120 token = Token (gherkin_line = line , location = location )
1221 assert tm .match_FeatureLine (token )
1322 assert token .matched_type == "FeatureLine"
@@ -25,6 +34,15 @@ def test_it_matches_FeatureLine_in_French():
2534 assert token .matched_text == "hello"
2635
2736
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+
2846def test_it_matches_bullet_Step ():
2947 tm = GherkinInMarkdownTokenMatcher ("en" )
3048 line = GherkinLine (""" * Given I have 3 cukes""" , location ["line" ])
@@ -41,21 +59,33 @@ def test_it_matches_plus_Step():
4159 line = GherkinLine (""" + Given I have 3 cukes""" , location ["line" ])
4260 token = Token (gherkin_line = line , location = location )
4361 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
4967
5068def test_it_matches_hyphen_Step ():
5169 tm = GherkinInMarkdownTokenMatcher ("en" )
5270 line = GherkinLine (""" - Given I have 3 cukes""" , location ["line" ])
5371 token = Token (gherkin_line = line , location = location )
5472 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
5989
6090
6191def test_it_matches_arbitrary_text_as_Other ():
@@ -156,19 +186,6 @@ def test_it_does_not_match_table_row_indented_6_space():
156186 assert not tm .match_TableRow (token )
157187
158188
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-
172189def test_it_matches_indented_tags ():
173190 tm = GherkinInMarkdownTokenMatcher ("en" )
174191
@@ -238,6 +255,34 @@ def test_it_matches_ExamplesLine():
238255 line = GherkinLine ("""## Examples: """ , location ["line" ])
239256 token = Token (gherkin_line = line , location = location )
240257 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