cuke_modeler 0.0.2 → 0.1.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.
Files changed (95) hide show
  1. data/.travis.yml +23 -0
  2. data/Gemfile +22 -4
  3. data/History.rdoc +6 -0
  4. data/Rakefile +26 -26
  5. data/cuke_modeler.gemspec +3 -1
  6. data/features/modeling/{background_modeling.feature → gherkin/background_modeling.feature} +1 -11
  7. data/features/modeling/{background_output.feature → gherkin/background_output.feature} +1 -0
  8. data/features/modeling/{directory_modeling.feature → gherkin/directory_modeling.feature} +1 -11
  9. data/features/modeling/{directory_output.feature → gherkin/directory_output.feature} +1 -0
  10. data/features/modeling/{doc_string_modeling.feature → gherkin/doc_string_modeling.feature} +1 -11
  11. data/features/modeling/{doc_string_output.feature → gherkin/doc_string_output.feature} +1 -0
  12. data/features/modeling/{example_modeling.feature → gherkin/example_modeling.feature} +1 -11
  13. data/features/modeling/{example_output.feature → gherkin/example_output.feature} +1 -0
  14. data/features/modeling/{feature_file_modeling.feature → gherkin/feature_file_modeling.feature} +1 -11
  15. data/features/modeling/{feature_file_output.feature → gherkin/feature_file_output.feature} +1 -0
  16. data/features/modeling/{feature_modeling.feature → gherkin/feature_modeling.feature} +1 -11
  17. data/features/modeling/{feature_output.feature → gherkin/feature_output.feature} +1 -0
  18. data/features/modeling/{outline_modeling.feature → gherkin/outline_modeling.feature} +1 -11
  19. data/features/modeling/{outline_output.feature → gherkin/outline_output.feature} +1 -0
  20. data/features/modeling/{row_modeling.feature → gherkin/row_modeling.feature} +1 -10
  21. data/features/modeling/{row_output.feature → gherkin/row_output.feature} +1 -0
  22. data/features/modeling/{scenario_modeling.feature → gherkin/scenario_modeling.feature} +1 -11
  23. data/features/modeling/{scenario_output.feature → gherkin/scenario_output.feature} +1 -0
  24. data/features/modeling/{step_modeling.feature → gherkin/step_modeling.feature} +1 -11
  25. data/features/modeling/{step_output.feature → gherkin/step_output.feature} +1 -0
  26. data/features/modeling/{table_modeling.feature → gherkin/table_modeling.feature} +1 -11
  27. data/features/modeling/{table_output.feature → gherkin/table_output.feature} +1 -0
  28. data/features/modeling/{table_row_modeling.feature → gherkin/table_row_modeling.feature} +1 -11
  29. data/features/modeling/{table_row_output.feature → gherkin/table_row_output.feature} +1 -0
  30. data/features/modeling/{tag_modeling.feature → gherkin/tag_modeling.feature} +1 -11
  31. data/features/modeling/{tag_output.feature → gherkin/tag_output.feature} +1 -0
  32. data/features/modeling/gherkin3/background_modeling.feature +64 -0
  33. data/features/modeling/gherkin3/background_output.feature +131 -0
  34. data/features/modeling/gherkin3/directory_modeling.feature +110 -0
  35. data/features/modeling/gherkin3/directory_output.feature +14 -0
  36. data/features/modeling/gherkin3/doc_string_modeling.feature +53 -0
  37. data/features/modeling/gherkin3/doc_string_output.feature +72 -0
  38. data/features/modeling/gherkin3/example_modeling.feature +100 -0
  39. data/features/modeling/gherkin3/example_output.feature +207 -0
  40. data/features/modeling/gherkin3/feature_file_modeling.feature +54 -0
  41. data/features/modeling/gherkin3/feature_file_output.feature +14 -0
  42. data/features/modeling/gherkin3/feature_modeling.feature +155 -0
  43. data/features/modeling/gherkin3/feature_output.feature +249 -0
  44. data/features/modeling/gherkin3/outline_modeling.feature +89 -0
  45. data/features/modeling/gherkin3/outline_output.feature +255 -0
  46. data/features/modeling/gherkin3/row_modeling.feature +68 -0
  47. data/features/modeling/gherkin3/row_output.feature +28 -0
  48. data/features/modeling/gherkin3/scenario_modeling.feature +78 -0
  49. data/features/modeling/gherkin3/scenario_output.feature +148 -0
  50. data/features/modeling/gherkin3/step_modeling.feature +75 -0
  51. data/features/modeling/gherkin3/step_output.feature +53 -0
  52. data/features/modeling/gherkin3/table_modeling.feature +42 -0
  53. data/features/modeling/gherkin3/table_output.feature +43 -0
  54. data/features/modeling/gherkin3/table_row_modeling.feature +57 -0
  55. data/features/modeling/gherkin3/table_row_output.feature +28 -0
  56. data/features/modeling/gherkin3/tag_modeling.feature +49 -0
  57. data/features/modeling/gherkin3/tag_output.feature +17 -0
  58. data/features/step_definitions/background_steps.rb +5 -1
  59. data/features/step_definitions/doc_string_steps.rb +5 -1
  60. data/features/step_definitions/feature_steps.rb +5 -1
  61. data/features/step_definitions/outline_steps.rb +10 -4
  62. data/features/step_definitions/step_steps.rb +10 -2
  63. data/features/step_definitions/table_steps.rb +6 -2
  64. data/features/step_definitions/tag_steps.rb +15 -3
  65. data/features/step_definitions/test_steps.rb +7 -2
  66. data/features/support/env.rb +21 -9
  67. data/gemfiles/gherkin.gemfile +17 -0
  68. data/gemfiles/gherkin3.gemfile +15 -0
  69. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +146 -0
  70. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +206 -0
  71. data/lib/cuke_modeler/parsing.rb +61 -20
  72. data/lib/cuke_modeler/raw.rb +1 -1
  73. data/lib/cuke_modeler/row.rb +2 -2
  74. data/lib/cuke_modeler/table.rb +2 -2
  75. data/lib/cuke_modeler/table_row.rb +1 -1
  76. data/lib/cuke_modeler/version.rb +1 -1
  77. data/spec/integration/example_integration_spec.rb +2 -1
  78. data/spec/integration/feature_integration_spec.rb +7 -4
  79. data/spec/integration/outline_integration_spec.rb +4 -2
  80. data/spec/integration/tag_integration_spec.rb +2 -1
  81. data/spec/spec_helper.rb +6 -0
  82. data/spec/unit/background_unit_spec.rb +17 -0
  83. data/spec/unit/doc_string_unit_spec.rb +17 -0
  84. data/spec/unit/example_unit_spec.rb +18 -1
  85. data/spec/unit/feature_file_unit_spec.rb +2 -2
  86. data/spec/unit/feature_unit_spec.rb +16 -0
  87. data/spec/unit/outline_unit_spec.rb +20 -1
  88. data/spec/unit/row_unit_spec.rb +18 -0
  89. data/spec/unit/scenario_unit_spec.rb +17 -0
  90. data/spec/unit/step_unit_spec.rb +17 -0
  91. data/spec/unit/table_row_unit_spec.rb +18 -0
  92. data/spec/unit/table_unit_spec.rb +16 -0
  93. data/spec/unit/tag_unit_spec.rb +17 -0
  94. metadata +147 -60
  95. data/features/step_definitions/spec_steps.rb +0 -18
@@ -0,0 +1,42 @@
1
+ @gherkin3
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
+ @gherkin3
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
+ @gherkin3
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
+ @gherkin3
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,49 @@
1
+ @gherkin3
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
+ | a value |
29
+ """
30
+ When the file is read
31
+
32
+
33
+ Scenario: The raw tag element is modeled.
34
+ Then the feature tag correctly stores its underlying implementation
35
+ And the test tag correctly stores its underlying implementation
36
+ And the example tag correctly stores its underlying implementation
37
+
38
+ Scenario: The tag's source line is modeled.
39
+ Then the feature tag source line "1"
40
+ And the test tag source line "4"
41
+ And the example tag source line "8"
42
+
43
+ Scenario: The tag name is modeled.
44
+ Then the feature tag name is "@feature_tag"
45
+ And the test tag name is "@outline_tag"
46
+ And the example tag name is "@example_tag"
47
+
48
+ Scenario: Convenient output of a tag
49
+ Then the tag has convenient output
@@ -0,0 +1,17 @@
1
+ @gherkin3
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,11 @@ 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
- actual = raw_element['keyword']
69
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
70
+ actual = raw_element[:keyword]
71
+ else
72
+ actual = raw_element['keyword']
73
+ end
70
74
 
71
75
  assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
72
76
  end
@@ -47,7 +47,11 @@ 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
- raw_element.has_key?('content_type').should be_true
50
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
51
+ raw_element.has_key?(:contentType).should be_true
52
+ else
53
+ raw_element.has_key?('content_type').should be_true
54
+ end
51
55
  end
52
56
 
53
57
  Then(/^the doc string has convenient output$/) do
@@ -77,7 +77,11 @@ Then /^(?:the )?feature(?: "([^"]*)")? correctly stores its underlying implement
77
77
 
78
78
  raw_element = @parsed_files[file - 1].feature.raw_element
79
79
 
80
- raw_element.has_key?('elements').should be_true
80
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
81
+ raw_element.has_key?(:scenarioDefinitions).should be_true
82
+ else
83
+ raw_element.has_key?('elements').should be_true
84
+ end
81
85
  end
82
86
 
83
87
  Then(/^the feature has convenient output$/) do
@@ -193,8 +193,11 @@ 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
-
197
- raw_element.has_key?('cells').should be_true
196
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
197
+ raw_element.has_key?(:cells).should be_true
198
+ else
199
+ raw_element.has_key?('cells').should be_true
200
+ end
198
201
  end
199
202
 
200
203
  Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file, test, example|
@@ -203,8 +206,11 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
203
206
  example ||= 1
204
207
 
205
208
  raw_element = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].raw_element
206
-
207
- raw_element.has_key?('rows').should be_true
209
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
210
+ raw_element.has_key?(:tableHeader).should be_true
211
+ else
212
+ raw_element.has_key?('rows').should be_true
213
+ end
208
214
  end
209
215
 
210
216
  Then(/^the row has convenient output$/) do
@@ -108,7 +108,11 @@ 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
- raw_element.has_key?('keyword').should be_true
111
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
112
+ raw_element.has_key?(:keyword).should be_true
113
+ else
114
+ raw_element.has_key?('keyword').should be_true
115
+ end
112
116
  end
113
117
 
114
118
  Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? table row(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, step, row, properties|
@@ -135,7 +139,11 @@ Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)
135
139
 
136
140
  raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements[row - 1].raw_element
137
141
 
138
- raw_element.has_key?('cells').should be_true
142
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
143
+ raw_element.has_key?(:cells).should be_true
144
+ else
145
+ raw_element.has_key?('cells').should be_true
146
+ end
139
147
  end
140
148
 
141
149
  Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? table row(?: "([^"]*)")? cells are as follows:$/ do |file, test, step, row, cells|
@@ -17,8 +17,12 @@ 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
- raw_element.is_a?(Array).should be_true
21
- raw_element.each { |row| row.has_key?('cells').should be_true }
20
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
21
+ expect(raw_element).to have_key(:rows)
22
+ else
23
+ raw_element.is_a?(Array).should be_true
24
+ raw_element.each { |row| row.has_key?('cells').should be_true }
25
+ end
22
26
  end
23
27
 
24
28
  Given(/^a table row element$/) do
@@ -1,19 +1,31 @@
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
- raw_element.has_key?('name').should be_true
4
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
5
+ raw_element.has_key?(:name).should be_true
6
+ else
7
+ raw_element.has_key?('name').should be_true
8
+ end
5
9
  end
6
10
 
7
11
  When(/^the test tag correctly stores its underlying implementation$/) do
8
12
  raw_element = @parsed_files.first.feature.tests.first.tag_elements.first.raw_element
9
13
 
10
- raw_element.has_key?('name').should be_true
14
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
15
+ raw_element.has_key?(:name).should be_true
16
+ else
17
+ raw_element.has_key?('name').should be_true
18
+ end
11
19
  end
12
20
 
13
21
  When(/^the example tag correctly stores its underlying implementation$/) do
14
22
  raw_element = @parsed_files.first.feature.tests.first.examples.first.tag_elements.first.raw_element
15
23
 
16
- raw_element.has_key?('name').should be_true
24
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
25
+ raw_element.has_key?(:name).should be_true
26
+ else
27
+ raw_element.has_key?('name').should be_true
28
+ end
17
29
  end
18
30
 
19
31
  Then(/^the feature tag name is "([^"]*)"$/) do |tag_name|
@@ -99,8 +99,13 @@ 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
- expected = ['Scenario', 'Scenario Outline']
103
- actual = raw_element['keyword']
102
+ if Gem.loaded_specs['gherkin'].version.version[/^3/]
103
+ expected = ['Scenario', 'Scenario Outline']
104
+ actual = raw_element[:keyword]
105
+ else
106
+ expected = ['Scenario', 'Scenario Outline']
107
+ actual = raw_element['keyword']
108
+ end
104
109
 
105
110
  expected.include?(actual).should be_true
106
111
  end
@@ -10,18 +10,30 @@ require File.dirname(__FILE__) + '/../../lib/cuke_modeler'
10
10
 
11
11
 
12
12
  Before do
13
- @default_file_directory = "#{File.dirname(__FILE__)}/../temp_files"
14
- @default_feature_file_name = 'test_feature.feature'
15
- @default_step_file_name = 'test_steps.rb'
16
- @test_file_directory = "#{File.dirname(__FILE__)}/../test_files"
17
- @test_step_file_location = "#{@default_file_directory}/#{@default_step_file_name}"
18
- @spec_directory = "#{File.dirname(__FILE__)}/../../spec"
19
-
20
- FileUtils.mkdir(@default_file_directory)
13
+ begin
14
+ @default_file_directory = "#{File.dirname(__FILE__)}/../temp_files"
15
+ @default_feature_file_name = 'test_feature.feature'
16
+ @default_step_file_name = 'test_steps.rb'
17
+ @test_file_directory = "#{File.dirname(__FILE__)}/../test_files"
18
+ @test_step_file_location = "#{@default_file_directory}/#{@default_step_file_name}"
19
+ @spec_directory = "#{File.dirname(__FILE__)}/../../spec"
20
+
21
+ FileUtils.mkdir(@default_file_directory)
22
+ rescue => e
23
+ $stdout.puts 'Problem caught in Before hook!'
24
+ $stdout.puts "Type: #{e.class}"
25
+ $stdout.puts "Message: #{e.message}"
26
+ end
21
27
  end
22
28
 
23
29
  After do
24
- FileUtils.remove_dir(@default_file_directory, true)
30
+ begin
31
+ FileUtils.remove_dir(@default_file_directory, true)
32
+ rescue => e
33
+ $stdout.puts 'Problem caught in After hook!'
34
+ $stdout.puts "Type: #{e.class}"
35
+ $stdout.puts "Message: #{e.message}"
36
+ end
25
37
  end
26
38
 
27
39