cuke_modeler 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -1
- data/History.rdoc +9 -2
- data/Rakefile +10 -1
- data/cuke_modeler.gemspec +1 -1
- data/features/modeling/gherkin4/background_modeling.feature +64 -0
- data/features/modeling/gherkin4/background_output.feature +131 -0
- data/features/modeling/gherkin4/directory_modeling.feature +110 -0
- data/features/modeling/gherkin4/directory_output.feature +14 -0
- data/features/modeling/gherkin4/doc_string_modeling.feature +53 -0
- data/features/modeling/gherkin4/doc_string_output.feature +72 -0
- data/features/modeling/gherkin4/example_modeling.feature +100 -0
- data/features/modeling/gherkin4/example_output.feature +193 -0
- data/features/modeling/gherkin4/feature_file_modeling.feature +54 -0
- data/features/modeling/gherkin4/feature_file_output.feature +14 -0
- data/features/modeling/gherkin4/feature_modeling.feature +153 -0
- data/features/modeling/gherkin4/feature_output.feature +245 -0
- data/features/modeling/gherkin4/outline_modeling.feature +89 -0
- data/features/modeling/gherkin4/outline_output.feature +198 -0
- data/features/modeling/gherkin4/row_modeling.feature +68 -0
- data/features/modeling/gherkin4/row_output.feature +28 -0
- data/features/modeling/gherkin4/scenario_modeling.feature +78 -0
- data/features/modeling/gherkin4/scenario_output.feature +148 -0
- data/features/modeling/gherkin4/step_modeling.feature +75 -0
- data/features/modeling/gherkin4/step_output.feature +53 -0
- data/features/modeling/gherkin4/table_modeling.feature +42 -0
- data/features/modeling/gherkin4/table_output.feature +43 -0
- data/features/modeling/gherkin4/table_row_modeling.feature +57 -0
- data/features/modeling/gherkin4/table_row_output.feature +28 -0
- data/features/modeling/gherkin4/tag_modeling.feature +48 -0
- data/features/modeling/gherkin4/tag_output.feature +17 -0
- data/features/step_definitions/background_steps.rb +1 -1
- data/features/step_definitions/doc_string_steps.rb +1 -1
- data/features/step_definitions/feature_steps.rb +7 -4
- data/features/step_definitions/outline_steps.rb +2 -2
- data/features/step_definitions/step_steps.rb +2 -2
- data/features/step_definitions/table_steps.rb +1 -1
- data/features/step_definitions/tag_steps.rb +3 -3
- data/features/step_definitions/test_steps.rb +1 -1
- data/gemfiles/gherkin.gemfile +1 -0
- data/gemfiles/gherkin3.gemfile +2 -1
- data/gemfiles/gherkin4.gemfile +16 -0
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +220 -0
- data/lib/cuke_modeler/example.rb +1 -1
- data/lib/cuke_modeler/parsing.rb +73 -44
- data/lib/cuke_modeler/version.rb +1 -1
- data/spec/spec_helper.rb +10 -4
- data/spec/unit/background_unit_spec.rb +17 -9
- data/spec/unit/bare_bones_unit_specs.rb +3 -1
- data/spec/unit/containing_element_unit_specs.rb +3 -1
- data/spec/unit/directory_unit_spec.rb +5 -5
- data/spec/unit/doc_string_unit_spec.rb +13 -5
- data/spec/unit/example_unit_spec.rb +44 -9
- data/spec/unit/feature_element_unit_spec.rb +5 -5
- data/spec/unit/feature_element_unit_specs.rb +3 -1
- data/spec/unit/feature_file_unit_spec.rb +5 -5
- data/spec/unit/feature_unit_spec.rb +17 -9
- data/spec/unit/nested_element_unit_specs.rb +3 -1
- data/spec/unit/outline_unit_spec.rb +18 -10
- data/spec/unit/parsing_unit_spec.rb +2 -2
- data/spec/unit/prepopulated_unit_specs.rb +3 -1
- data/spec/unit/raw_element_unit_specs.rb +3 -1
- data/spec/unit/row_unit_spec.rb +15 -8
- data/spec/unit/scenario_unit_spec.rb +19 -11
- data/spec/unit/sourced_element_unit_specs.rb +3 -1
- data/spec/unit/step_unit_spec.rb +14 -6
- data/spec/unit/table_row_unit_spec.rb +15 -8
- data/spec/unit/table_unit_spec.rb +13 -5
- data/spec/unit/tag_unit_spec.rb +14 -6
- data/spec/unit/tagged_element_unit_specs.rb +3 -1
- data/spec/unit/test_element_unit_spec.rb +6 -6
- data/spec/unit/test_element_unit_specs.rb +3 -1
- metadata +86 -55
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@gherkin4
|
|
2
|
+
Feature: Table elements can be modeled.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Acceptance criteria
|
|
6
|
+
|
|
7
|
+
1. All conceptual pieces of a table can be modeled:
|
|
8
|
+
- the table's contents
|
|
9
|
+
- the table's raw element
|
|
10
|
+
|
|
11
|
+
2. Tables can be outputted in a convenient form
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Background: Test file setup.
|
|
15
|
+
Given the following feature file:
|
|
16
|
+
"""
|
|
17
|
+
Feature:
|
|
18
|
+
|
|
19
|
+
Scenario:
|
|
20
|
+
* some data filled step:
|
|
21
|
+
| value 1 | value 2 |
|
|
22
|
+
| value 3 | value 4 |
|
|
23
|
+
* some data filled step:
|
|
24
|
+
| value 1 |
|
|
25
|
+
| value 2 |
|
|
26
|
+
"""
|
|
27
|
+
When the file is read
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Scenario: The table's contents are modeled.
|
|
31
|
+
Then the step "1" table has the following contents:
|
|
32
|
+
| value 1 | value 2 |
|
|
33
|
+
| value 3 | value 4 |
|
|
34
|
+
And the step "2" table has the following contents:
|
|
35
|
+
| value 1 |
|
|
36
|
+
| value 2 |
|
|
37
|
+
|
|
38
|
+
Scenario: The raw table element is modeled.
|
|
39
|
+
Then the table correctly stores its underlying implementation
|
|
40
|
+
|
|
41
|
+
Scenario: Convenient output of a table
|
|
42
|
+
Then the table has convenient output
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@gherkin4
|
|
2
|
+
Feature: Outputting table elements
|
|
3
|
+
|
|
4
|
+
The output of an element model is a representation of the element as it would
|
|
5
|
+
appear in gherkin.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Scenario: Output of a table that has one row
|
|
9
|
+
Given a table element based on the following gherkin:
|
|
10
|
+
"""
|
|
11
|
+
|value|
|
|
12
|
+
"""
|
|
13
|
+
When it is outputted
|
|
14
|
+
Then the following text is provided:
|
|
15
|
+
"""
|
|
16
|
+
| value |
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
Scenario: Output of a table that has multiple rows
|
|
20
|
+
Given a table element based on the following gherkin:
|
|
21
|
+
"""
|
|
22
|
+
|value1|
|
|
23
|
+
|value2|
|
|
24
|
+
"""
|
|
25
|
+
When it is outputted
|
|
26
|
+
Then the following text is provided:
|
|
27
|
+
"""
|
|
28
|
+
| value1 |
|
|
29
|
+
| value2 |
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
Scenario: Whitespace buffers are based on the longest value in a column
|
|
33
|
+
Given a table element based on the following gherkin:
|
|
34
|
+
"""
|
|
35
|
+
|value|x|
|
|
36
|
+
|y|another_value|
|
|
37
|
+
"""
|
|
38
|
+
When it is outputted
|
|
39
|
+
Then the following text is provided:
|
|
40
|
+
"""
|
|
41
|
+
| value | x |
|
|
42
|
+
| y | another_value |
|
|
43
|
+
"""
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@gherkin4
|
|
2
|
+
Feature: Table Row elements can be modeled.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Acceptance criteria
|
|
6
|
+
|
|
7
|
+
1. All conceptual pieces of a table row can be modeled:
|
|
8
|
+
- the row's source line
|
|
9
|
+
- the row's cells
|
|
10
|
+
- the row's raw element
|
|
11
|
+
|
|
12
|
+
2. Rows can be outputted in a convenient form
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Background: Test file setup.
|
|
16
|
+
Given the following feature file:
|
|
17
|
+
"""
|
|
18
|
+
Feature:
|
|
19
|
+
|
|
20
|
+
Scenario:
|
|
21
|
+
* some data filled step:
|
|
22
|
+
| value 1 | value 2 |
|
|
23
|
+
| value 3 | value 4 |
|
|
24
|
+
* some data filled step:
|
|
25
|
+
| value 1 |
|
|
26
|
+
| value 2 |
|
|
27
|
+
"""
|
|
28
|
+
When the file is read
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Scenario: The raw table row element is modeled.
|
|
32
|
+
Then the step table row correctly stores its underlying implementation
|
|
33
|
+
|
|
34
|
+
Scenario: The table row's source line is modeled.
|
|
35
|
+
Then step "1" table row "1" is found to have the following properties:
|
|
36
|
+
| source_line | 5 |
|
|
37
|
+
And step "1" table row "2" is found to have the following properties:
|
|
38
|
+
| source_line | 6 |
|
|
39
|
+
And step "2" table row "1" is found to have the following properties:
|
|
40
|
+
| source_line | 8 |
|
|
41
|
+
And step "2" table row "2" is found to have the following properties:
|
|
42
|
+
| source_line | 9 |
|
|
43
|
+
|
|
44
|
+
Scenario: The table row's cells are modeled.
|
|
45
|
+
Then step "1" table row "1" cells are as follows:
|
|
46
|
+
| value 1 |
|
|
47
|
+
| value 2 |
|
|
48
|
+
And step "1" table row "2" cells are as follows:
|
|
49
|
+
| value 3 |
|
|
50
|
+
| value 4 |
|
|
51
|
+
And step "2" table row "1" cells are as follows:
|
|
52
|
+
| value 1 |
|
|
53
|
+
And step "2" table row "2" cells are as follows:
|
|
54
|
+
| value 2 |
|
|
55
|
+
|
|
56
|
+
Scenario: Convenient output of a table row
|
|
57
|
+
Then the table row has convenient output
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@gherkin4
|
|
2
|
+
Feature: Outputting table row elements
|
|
3
|
+
|
|
4
|
+
The output of an element model is a representation of the element as it would
|
|
5
|
+
appear in gherkin.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Scenario: Output of a table row that has one cell
|
|
9
|
+
Given a table row element based on the following gherkin:
|
|
10
|
+
"""
|
|
11
|
+
|value|
|
|
12
|
+
"""
|
|
13
|
+
When it is outputted
|
|
14
|
+
Then the following text is provided:
|
|
15
|
+
"""
|
|
16
|
+
| value |
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
Scenario: Output of a table row that has multiple cells
|
|
20
|
+
Given a table row element based on the following gherkin:
|
|
21
|
+
"""
|
|
22
|
+
|value|another_value|
|
|
23
|
+
"""
|
|
24
|
+
When it is outputted
|
|
25
|
+
Then the following text is provided:
|
|
26
|
+
"""
|
|
27
|
+
| value | another_value |
|
|
28
|
+
"""
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@gherkin4
|
|
2
|
+
Feature: Tag elements can be modeled.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Acceptance criteria
|
|
6
|
+
|
|
7
|
+
1. All conceptual pieces of a tag can be modeled:
|
|
8
|
+
- the tag's name
|
|
9
|
+
- the tags's source line
|
|
10
|
+
- the tags's raw element
|
|
11
|
+
|
|
12
|
+
2. Features can be outputted in a convenient form
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Background: Test file setup.
|
|
16
|
+
Given the following feature file:
|
|
17
|
+
"""
|
|
18
|
+
@feature_tag
|
|
19
|
+
Feature:
|
|
20
|
+
|
|
21
|
+
@outline_tag
|
|
22
|
+
Scenario Outline:
|
|
23
|
+
* a step
|
|
24
|
+
|
|
25
|
+
@example_tag
|
|
26
|
+
Examples:
|
|
27
|
+
| a param |
|
|
28
|
+
"""
|
|
29
|
+
When the file is read
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Scenario: The raw tag element is modeled.
|
|
33
|
+
Then the feature tag correctly stores its underlying implementation
|
|
34
|
+
And the test tag correctly stores its underlying implementation
|
|
35
|
+
And the example tag correctly stores its underlying implementation
|
|
36
|
+
|
|
37
|
+
Scenario: The tag's source line is modeled.
|
|
38
|
+
Then the feature tag source line "1"
|
|
39
|
+
And the test tag source line "4"
|
|
40
|
+
And the example tag source line "8"
|
|
41
|
+
|
|
42
|
+
Scenario: The tag name is modeled.
|
|
43
|
+
Then the feature tag name is "@feature_tag"
|
|
44
|
+
And the test tag name is "@outline_tag"
|
|
45
|
+
And the example tag name is "@example_tag"
|
|
46
|
+
|
|
47
|
+
Scenario: Convenient output of a tag
|
|
48
|
+
Then the tag has convenient output
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@gherkin4
|
|
2
|
+
Feature: Outputting tag elements
|
|
3
|
+
|
|
4
|
+
The output of an element model is a representation of the element as it would
|
|
5
|
+
appear in gherkin.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Scenario: Output of a tag that has a name
|
|
9
|
+
Given a tag element based on the following gherkin:
|
|
10
|
+
"""
|
|
11
|
+
@some_tag
|
|
12
|
+
"""
|
|
13
|
+
When it is outputted
|
|
14
|
+
Then the following text is provided:
|
|
15
|
+
"""
|
|
16
|
+
@some_tag
|
|
17
|
+
"""
|
|
@@ -66,7 +66,7 @@ Then(/^the(?: feature "([^"]*)")? background correctly stores its underlying imp
|
|
|
66
66
|
raw_element = @parsed_files[file - 1].feature.background.raw_element
|
|
67
67
|
|
|
68
68
|
expected = 'Background'
|
|
69
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
69
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
70
70
|
actual = raw_element[:keyword]
|
|
71
71
|
else
|
|
72
72
|
actual = raw_element['keyword']
|
|
@@ -47,7 +47,7 @@ Then(/^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"
|
|
|
47
47
|
|
|
48
48
|
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.raw_element
|
|
49
49
|
|
|
50
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
50
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
51
51
|
raw_element.has_key?(:contentType).should be_true
|
|
52
52
|
else
|
|
53
53
|
raw_element.has_key?('content_type').should be_true
|
|
@@ -77,10 +77,13 @@ Then /^(?:the )?feature(?: "([^"]*)")? correctly stores its underlying implement
|
|
|
77
77
|
|
|
78
78
|
raw_element = @parsed_files[file - 1].feature.raw_element
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
case
|
|
81
|
+
when Gem.loaded_specs['gherkin'].version.version[/^4/]
|
|
82
|
+
expect(raw_element).to have_key(:children)
|
|
83
|
+
when Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
84
|
+
expect(raw_element).to have_key(:scenarioDefinitions)
|
|
85
|
+
else
|
|
86
|
+
expect(raw_element).to have_key('elements')
|
|
84
87
|
end
|
|
85
88
|
end
|
|
86
89
|
|
|
@@ -193,7 +193,7 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
|
|
|
193
193
|
row ||= 1
|
|
194
194
|
|
|
195
195
|
raw_element = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].row_elements[row - 1].raw_element
|
|
196
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
196
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
197
197
|
raw_element.has_key?(:cells).should be_true
|
|
198
198
|
else
|
|
199
199
|
raw_element.has_key?('cells').should be_true
|
|
@@ -206,7 +206,7 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
|
|
|
206
206
|
example ||= 1
|
|
207
207
|
|
|
208
208
|
raw_element = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].raw_element
|
|
209
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
209
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
210
210
|
raw_element.has_key?(:tableHeader).should be_true
|
|
211
211
|
else
|
|
212
212
|
raw_element.has_key?('rows').should be_true
|
|
@@ -108,7 +108,7 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? c
|
|
|
108
108
|
|
|
109
109
|
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].raw_element
|
|
110
110
|
|
|
111
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
111
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
112
112
|
raw_element.has_key?(:keyword).should be_true
|
|
113
113
|
else
|
|
114
114
|
raw_element.has_key?('keyword').should be_true
|
|
@@ -139,7 +139,7 @@ Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)
|
|
|
139
139
|
|
|
140
140
|
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements[row - 1].raw_element
|
|
141
141
|
|
|
142
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
142
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
143
143
|
raw_element.has_key?(:cells).should be_true
|
|
144
144
|
else
|
|
145
145
|
raw_element.has_key?('cells').should be_true
|
|
@@ -17,7 +17,7 @@ Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"
|
|
|
17
17
|
|
|
18
18
|
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.raw_element
|
|
19
19
|
|
|
20
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
20
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
21
21
|
expect(raw_element).to have_key(:rows)
|
|
22
22
|
else
|
|
23
23
|
raw_element.is_a?(Array).should be_true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Then /^the feature tag correctly stores its underlying implementation$/ do
|
|
2
2
|
raw_element = @parsed_files.first.feature.tag_elements.first.raw_element
|
|
3
3
|
|
|
4
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
4
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
5
5
|
raw_element.has_key?(:name).should be_true
|
|
6
6
|
else
|
|
7
7
|
raw_element.has_key?('name').should be_true
|
|
@@ -11,7 +11,7 @@ end
|
|
|
11
11
|
When(/^the test tag correctly stores its underlying implementation$/) do
|
|
12
12
|
raw_element = @parsed_files.first.feature.tests.first.tag_elements.first.raw_element
|
|
13
13
|
|
|
14
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
14
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
15
15
|
raw_element.has_key?(:name).should be_true
|
|
16
16
|
else
|
|
17
17
|
raw_element.has_key?('name').should be_true
|
|
@@ -21,7 +21,7 @@ end
|
|
|
21
21
|
When(/^the example tag correctly stores its underlying implementation$/) do
|
|
22
22
|
raw_element = @parsed_files.first.feature.tests.first.examples.first.tag_elements.first.raw_element
|
|
23
23
|
|
|
24
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
24
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
25
25
|
raw_element.has_key?(:name).should be_true
|
|
26
26
|
else
|
|
27
27
|
raw_element.has_key?('name').should be_true
|
|
@@ -99,7 +99,7 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? correctly stores its
|
|
|
99
99
|
|
|
100
100
|
raw_element = @parsed_files[file - 1].feature.tests[test - 1].raw_element
|
|
101
101
|
|
|
102
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3/]
|
|
102
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
103
103
|
expected = ['Scenario', 'Scenario Outline']
|
|
104
104
|
actual = raw_element[:keyword]
|
|
105
105
|
else
|
data/gemfiles/gherkin.gemfile
CHANGED
data/gemfiles/gherkin3.gemfile
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
gemspec :path => "../"
|
|
4
|
-
gem "gherkin", "
|
|
4
|
+
gem "gherkin", "~> 3.0"
|
|
5
5
|
|
|
6
6
|
# cuke_modeler can play with pretty much any version of these but they all play differently with Ruby
|
|
7
7
|
if RUBY_VERSION =~ /^1\.8/
|
|
8
8
|
gem 'cucumber', '<1.3.0'
|
|
9
9
|
gem 'mime-types', '<2.0.0'
|
|
10
10
|
gem 'rest-client', '<1.7.0'
|
|
11
|
+
gem 'rake', '< 11.0' # Rake dropped 1.8.x support after this version
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
if RUBY_VERSION =~ /^2\.[23456789]/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gemspec :path => "../"
|
|
4
|
+
gem "gherkin", "~> 4.0"
|
|
5
|
+
|
|
6
|
+
# cuke_modeler can play with pretty much any version of these but they all play differently with Ruby
|
|
7
|
+
if RUBY_VERSION =~ /^1\.8/
|
|
8
|
+
gem 'cucumber', '<1.3.0'
|
|
9
|
+
gem 'mime-types', '<2.0.0'
|
|
10
|
+
gem 'rest-client', '<1.7.0'
|
|
11
|
+
gem 'rake', '< 11.0' # Rake dropped 1.8.x support after this version
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
if RUBY_VERSION =~ /^2\.[23456789]/
|
|
15
|
+
gem 'test-unit'
|
|
16
|
+
end
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
module CukeModeler
|
|
2
|
+
class Gherkin4Adapter
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def adapt(parsed_ast)
|
|
6
|
+
adapt_feature!(parsed_ast[:feature]) if parsed_ast[:feature]
|
|
7
|
+
|
|
8
|
+
[parsed_ast[:feature]].compact
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def adapt_feature!(parsed_feature)
|
|
12
|
+
# Saving off the original data
|
|
13
|
+
parsed_feature['cuke_modeler_raw_adapter_output'] = Marshal::load(Marshal.dump(parsed_feature))
|
|
14
|
+
|
|
15
|
+
parsed_feature['name'] = parsed_feature.delete(:name)
|
|
16
|
+
parsed_feature['description'] = parsed_feature.delete(:description) || ''
|
|
17
|
+
parsed_feature['line'] = parsed_feature.delete(:location)[:line]
|
|
18
|
+
|
|
19
|
+
parsed_feature['elements'] = []
|
|
20
|
+
adapt_child_elements!(parsed_feature[:children])
|
|
21
|
+
parsed_feature['elements'].concat(parsed_feature.delete(:children))
|
|
22
|
+
|
|
23
|
+
parsed_feature['tags'] = []
|
|
24
|
+
parsed_feature[:tags].each do |tag|
|
|
25
|
+
adapt_tag!(tag)
|
|
26
|
+
end
|
|
27
|
+
parsed_feature['tags'].concat(parsed_feature.delete(:tags))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def adapt_child_elements!(parsed_children)
|
|
31
|
+
return if parsed_children.empty?
|
|
32
|
+
|
|
33
|
+
if parsed_children.first[:type] == :Background
|
|
34
|
+
adapt_background!(parsed_children.first)
|
|
35
|
+
|
|
36
|
+
remaining_children = parsed_children[1..-1]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
adapt_tests!(remaining_children || parsed_children)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def adapt_background!(parsed_background)
|
|
43
|
+
# Saving off the original data
|
|
44
|
+
parsed_background['cuke_modeler_raw_adapter_output'] = Marshal::load(Marshal.dump(parsed_background))
|
|
45
|
+
|
|
46
|
+
parsed_background['keyword'] = parsed_background.delete(:type).to_s
|
|
47
|
+
parsed_background['name'] = parsed_background.delete(:name)
|
|
48
|
+
parsed_background['description'] = parsed_background.delete(:description) || ''
|
|
49
|
+
parsed_background['line'] = parsed_background.delete(:location)[:line]
|
|
50
|
+
|
|
51
|
+
parsed_background['steps'] = []
|
|
52
|
+
parsed_background[:steps].each do |step|
|
|
53
|
+
adapt_step!(step)
|
|
54
|
+
end
|
|
55
|
+
parsed_background['steps'].concat(parsed_background.delete(:steps))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def adapt_tests!(parsed_tests)
|
|
59
|
+
return unless parsed_tests
|
|
60
|
+
|
|
61
|
+
parsed_tests.each do |test|
|
|
62
|
+
adapt_test!(test)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def adapt_test!(parsed_test)
|
|
67
|
+
# Saving off the original data
|
|
68
|
+
parsed_test['cuke_modeler_raw_adapter_output'] = Marshal::load(Marshal.dump(parsed_test))
|
|
69
|
+
|
|
70
|
+
parsed_test['keyword'] = parsed_test.delete(:type).to_s
|
|
71
|
+
|
|
72
|
+
case parsed_test['keyword']
|
|
73
|
+
when 'Scenario'
|
|
74
|
+
adapt_scenario!(parsed_test)
|
|
75
|
+
when 'ScenarioOutline'
|
|
76
|
+
parsed_test['keyword'] = 'Scenario Outline'
|
|
77
|
+
adapt_outline!(parsed_test)
|
|
78
|
+
else
|
|
79
|
+
raise(ArgumentError, "Unknown test type: #{parsed_test['keyword']}")
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def adapt_scenario!(parsed_test)
|
|
84
|
+
parsed_test['name'] = parsed_test.delete(:name)
|
|
85
|
+
parsed_test['description'] = parsed_test.delete(:description) || ''
|
|
86
|
+
parsed_test['line'] = parsed_test.delete(:location)[:line]
|
|
87
|
+
|
|
88
|
+
parsed_test['tags'] = []
|
|
89
|
+
parsed_test[:tags].each do |tag|
|
|
90
|
+
adapt_tag!(tag)
|
|
91
|
+
end
|
|
92
|
+
parsed_test['tags'].concat(parsed_test.delete(:tags))
|
|
93
|
+
|
|
94
|
+
parsed_test['steps'] = []
|
|
95
|
+
parsed_test[:steps].each do |step|
|
|
96
|
+
adapt_step!(step)
|
|
97
|
+
end
|
|
98
|
+
parsed_test['steps'].concat(parsed_test.delete(:steps))
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def adapt_outline!(parsed_test)
|
|
102
|
+
parsed_test['name'] = parsed_test.delete(:name)
|
|
103
|
+
parsed_test['description'] = parsed_test.delete(:description) || ''
|
|
104
|
+
parsed_test['line'] = parsed_test.delete(:location)[:line]
|
|
105
|
+
|
|
106
|
+
parsed_test['tags'] = []
|
|
107
|
+
parsed_test[:tags].each do |tag|
|
|
108
|
+
adapt_tag!(tag)
|
|
109
|
+
end
|
|
110
|
+
parsed_test['tags'].concat(parsed_test.delete(:tags))
|
|
111
|
+
|
|
112
|
+
parsed_test['steps'] = []
|
|
113
|
+
parsed_test[:steps].each do |step|
|
|
114
|
+
adapt_step!(step)
|
|
115
|
+
end
|
|
116
|
+
parsed_test['steps'].concat(parsed_test.delete(:steps))
|
|
117
|
+
|
|
118
|
+
parsed_test['examples'] = []
|
|
119
|
+
parsed_test[:examples].each do |step|
|
|
120
|
+
adapt_example!(step)
|
|
121
|
+
end
|
|
122
|
+
parsed_test['examples'].concat(parsed_test.delete(:examples))
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def adapt_example!(parsed_example)
|
|
126
|
+
# Saving off the original data
|
|
127
|
+
parsed_example['cuke_modeler_raw_adapter_output'] = Marshal::load(Marshal.dump(parsed_example))
|
|
128
|
+
|
|
129
|
+
parsed_example['name'] = parsed_example.delete(:name)
|
|
130
|
+
parsed_example['line'] = parsed_example.delete(:location)[:line]
|
|
131
|
+
parsed_example['description'] = parsed_example.delete(:description) || ''
|
|
132
|
+
|
|
133
|
+
parsed_example['rows'] = []
|
|
134
|
+
|
|
135
|
+
if parsed_example[:tableHeader]
|
|
136
|
+
parsed_example['rows'] << adapt_table_row!(parsed_example.delete(:tableHeader))
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
if parsed_example[:tableBody]
|
|
140
|
+
|
|
141
|
+
parsed_example[:tableBody].each do |row|
|
|
142
|
+
adapt_table_row!(row)
|
|
143
|
+
end
|
|
144
|
+
parsed_example['rows'].concat(parsed_example.delete(:tableBody))
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
parsed_example['tags'] = []
|
|
149
|
+
parsed_example[:tags].each do |tag|
|
|
150
|
+
adapt_tag!(tag)
|
|
151
|
+
end
|
|
152
|
+
parsed_example['tags'].concat(parsed_example.delete(:tags))
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def adapt_tag!(parsed_tag)
|
|
156
|
+
# Saving off the original data
|
|
157
|
+
parsed_tag['cuke_modeler_raw_adapter_output'] = Marshal::load(Marshal.dump(parsed_tag))
|
|
158
|
+
|
|
159
|
+
parsed_tag['name'] = parsed_tag.delete(:name)
|
|
160
|
+
parsed_tag['line'] = parsed_tag.delete(:location)[:line]
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def adapt_step!(parsed_step)
|
|
164
|
+
# Saving off the original data
|
|
165
|
+
parsed_step['cuke_modeler_raw_adapter_output'] = Marshal::load(Marshal.dump(parsed_step))
|
|
166
|
+
|
|
167
|
+
parsed_step['keyword'] = parsed_step.delete(:keyword)
|
|
168
|
+
parsed_step['name'] = parsed_step.delete(:text)
|
|
169
|
+
parsed_step['line'] = parsed_step.delete(:location)[:line]
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
step_argument = parsed_step[:argument]
|
|
173
|
+
|
|
174
|
+
if step_argument
|
|
175
|
+
case step_argument[:type]
|
|
176
|
+
when :DocString
|
|
177
|
+
adapt_doc_string!(step_argument)
|
|
178
|
+
parsed_step['doc_string'] = parsed_step.delete(:argument)
|
|
179
|
+
when :DataTable
|
|
180
|
+
adapt_step_table!(step_argument)
|
|
181
|
+
parsed_step['rows'] = parsed_step.delete(:argument)
|
|
182
|
+
else
|
|
183
|
+
raise(ArgumentError, "Unknown step argument type: #{step_argument[:type]}")
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def adapt_doc_string!(parsed_doc_string)
|
|
189
|
+
# Saving off the original data
|
|
190
|
+
parsed_doc_string['cuke_modeler_raw_adapter_output'] = Marshal::load(Marshal.dump(parsed_doc_string))
|
|
191
|
+
|
|
192
|
+
parsed_doc_string['value'] = parsed_doc_string.delete(:content)
|
|
193
|
+
parsed_doc_string['content_type'] = parsed_doc_string.delete(:contentType)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def adapt_step_table!(parsed_step_table)
|
|
197
|
+
# Saving off the original data
|
|
198
|
+
parsed_step_table['cuke_modeler_raw_adapter_output'] = Marshal::load(Marshal.dump(parsed_step_table))
|
|
199
|
+
|
|
200
|
+
parsed_step_table['rows'] = []
|
|
201
|
+
parsed_step_table[:rows].each do |row|
|
|
202
|
+
adapt_table_row!(row)
|
|
203
|
+
end
|
|
204
|
+
parsed_step_table['rows'].concat(parsed_step_table.delete(:rows))
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def adapt_table_row!(parsed_table_row)
|
|
208
|
+
# Saving off the original data
|
|
209
|
+
parsed_table_row['cuke_modeler_raw_adapter_output'] = Marshal::load(Marshal.dump(parsed_table_row))
|
|
210
|
+
|
|
211
|
+
parsed_table_row['line'] = parsed_table_row.delete(:location)[:line]
|
|
212
|
+
|
|
213
|
+
parsed_table_row['cells'] = parsed_table_row.delete(:cells).collect { |cell| cell[:value] }
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
parsed_table_row
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
end
|
|
220
|
+
end
|