cuke_modeler 0.4.1 → 1.0.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 +4 -4
- data/.gitignore +17 -17
- data/.travis.yml +1 -1
- data/Gemfile +4 -0
- data/History.rdoc +71 -3
- data/LICENSE.txt +22 -22
- data/README.md +24 -10
- data/Rakefile +2 -12
- data/cuke_modeler.gemspec +1 -1
- data/features/analysis/test_comparison.feature +37 -122
- data/features/modeling/background_modeling.feature +77 -0
- data/features/modeling/background_output.feature +42 -0
- data/features/modeling/cell_modeling.feature +23 -0
- data/features/modeling/cell_output.feature +22 -0
- data/features/modeling/directory_modeling.feature +65 -0
- data/features/modeling/directory_output.feature +12 -0
- data/features/modeling/doc_string_modeling.feature +61 -0
- data/features/modeling/doc_string_output.feature +32 -0
- data/features/modeling/example_modeling.feature +125 -0
- data/features/modeling/example_output.feature +39 -0
- data/features/modeling/feature_file_modeling.feature +40 -0
- data/features/modeling/feature_file_output.feature +12 -0
- data/features/modeling/feature_modeling.feature +109 -0
- data/features/modeling/feature_output.feature +104 -0
- data/features/modeling/model_output.feature +22 -0
- data/features/modeling/model_structure.feature +48 -0
- data/features/modeling/outline_modeling.feature +144 -0
- data/features/modeling/outline_output.feature +69 -0
- data/features/modeling/row_modeling.feature +48 -0
- data/features/modeling/row_output.feature +22 -0
- data/features/modeling/scenario_modeling.feature +118 -0
- data/features/modeling/scenario_output.feature +45 -0
- data/features/modeling/step_modeling.feature +84 -0
- data/features/modeling/step_output.feature +29 -0
- data/features/modeling/table_modeling.feature +50 -0
- data/features/modeling/table_output.feature +24 -0
- data/features/modeling/tag_modeling.feature +43 -0
- data/features/modeling/tag_output.feature +22 -0
- data/features/step_definitions/action_steps.rb +11 -1
- data/features/step_definitions/background_steps.rb +1 -85
- data/features/step_definitions/directory_steps.rb +2 -48
- data/features/step_definitions/doc_string_steps.rb +1 -67
- data/features/step_definitions/feature_file_steps.rb +2 -37
- data/features/step_definitions/feature_steps.rb +4 -100
- data/features/step_definitions/modeling_steps.rb +44 -0
- data/features/step_definitions/setup_steps.rb +19 -41
- data/features/step_definitions/step_steps.rb +2 -166
- data/features/step_definitions/table_steps.rb +1 -58
- data/features/step_definitions/tag_steps.rb +2 -72
- data/features/step_definitions/verification_steps.rb +152 -4
- data/features/support/env.rb +4 -6
- data/gemfiles/{gherkin.gemfile → gherkin2.gemfile} +4 -0
- data/gemfiles/gherkin3.gemfile +4 -0
- data/gemfiles/gherkin4.gemfile +4 -0
- data/lib/cuke_modeler.rb +24 -22
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +103 -31
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +103 -40
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +111 -50
- data/lib/cuke_modeler/containing.rb +255 -4
- data/lib/cuke_modeler/described.rb +28 -0
- data/lib/cuke_modeler/models/background.rb +66 -0
- data/lib/cuke_modeler/models/cell.rb +48 -0
- data/lib/cuke_modeler/models/directory.rb +95 -0
- data/lib/cuke_modeler/models/doc_string.rb +59 -0
- data/lib/cuke_modeler/models/example.rb +167 -0
- data/lib/cuke_modeler/models/feature.rb +106 -0
- data/lib/cuke_modeler/models/feature_file.rb +64 -0
- data/lib/cuke_modeler/models/model.rb +32 -0
- data/lib/cuke_modeler/models/outline.rb +79 -0
- data/lib/cuke_modeler/models/row.rb +49 -0
- data/lib/cuke_modeler/models/scenario.rb +69 -0
- data/lib/cuke_modeler/models/step.rb +68 -0
- data/lib/cuke_modeler/models/table.rb +67 -0
- data/lib/cuke_modeler/models/tag.rb +46 -0
- data/lib/cuke_modeler/named.rb +19 -0
- data/lib/cuke_modeler/nested.rb +22 -15
- data/lib/cuke_modeler/parsed.rb +11 -0
- data/lib/cuke_modeler/parsing.rb +66 -83
- data/lib/cuke_modeler/sourceable.rb +3 -11
- data/lib/cuke_modeler/stepped.rb +24 -0
- data/lib/cuke_modeler/taggable.rb +6 -29
- data/lib/cuke_modeler/version.rb +2 -1
- data/spec/integration/background_integration_spec.rb +332 -7
- data/spec/integration/cell_integration_spec.rb +321 -0
- data/spec/integration/directory_integration_spec.rb +175 -9
- data/spec/integration/doc_string_integration_spec.rb +318 -7
- data/spec/integration/example_integration_spec.rb +602 -19
- data/spec/integration/feature_file_integration_spec.rb +98 -3
- data/spec/integration/feature_integration_spec.rb +445 -27
- data/spec/integration/gherkin_2_adapter_spec.rb +122 -0
- data/spec/integration/gherkin_3_adapter_spec.rb +125 -0
- data/spec/integration/gherkin_4_adapter_spec.rb +123 -0
- data/spec/integration/model_integration_spec.rb +15 -0
- data/spec/integration/nested_integration_spec.rb +91 -0
- data/spec/integration/outline_integration_spec.rb +485 -12
- data/spec/integration/parsing_integration_spec.rb +85 -0
- data/spec/integration/row_integration_spec.rb +221 -18
- data/spec/integration/scenario_integration_spec.rb +368 -14
- data/spec/integration/shared/models_integration_specs.rb +18 -0
- data/spec/integration/step_integration_spec.rb +328 -77
- data/spec/integration/table_integration_spec.rb +242 -20
- data/spec/integration/tag_integration_spec.rb +178 -13
- data/spec/spec_helper.rb +32 -18
- data/spec/unit/background_unit_spec.rb +24 -44
- data/spec/unit/cell_unit_spec.rb +73 -0
- data/spec/unit/described_unit_spec.rb +23 -0
- data/spec/unit/directory_unit_spec.rb +52 -62
- data/spec/unit/doc_string_unit_spec.rb +47 -100
- data/spec/unit/example_unit_spec.rb +50 -296
- data/spec/unit/feature_file_unit_spec.rb +53 -52
- data/spec/unit/feature_unit_spec.rb +39 -83
- data/spec/unit/model_unit_spec.rb +15 -0
- data/spec/unit/named_unit_spec.rb +23 -0
- data/spec/unit/nested_unit_spec.rb +24 -21
- data/spec/unit/outline_unit_spec.rb +46 -69
- data/spec/unit/parsed_unit_spec.rb +27 -0
- data/spec/unit/parsing_unit_spec.rb +2 -70
- data/spec/unit/row_unit_spec.rb +22 -51
- data/spec/unit/scenario_unit_spec.rb +27 -59
- data/spec/unit/{bare_bones_unit_specs.rb → shared/bare_bones_models_unit_specs.rb} +2 -2
- data/spec/unit/shared/containing_models_unit_specs.rb +18 -0
- data/spec/unit/shared/described_models_unit_specs.rb +38 -0
- data/spec/unit/shared/models_unit_specs.rb +15 -0
- data/spec/unit/shared/named_models_unit_specs.rb +39 -0
- data/spec/unit/shared/nested_models_unit_specs.rb +51 -0
- data/spec/unit/shared/parsed_models_unit_specs.rb +39 -0
- data/spec/unit/shared/prepopulated_models_unit_specs.rb +18 -0
- data/spec/unit/shared/sourced_models_unit_specs.rb +39 -0
- data/spec/unit/shared/stepped_models_unit_specs.rb +46 -0
- data/spec/unit/shared/stringifiable_models_unit_specs.rb +18 -0
- data/spec/unit/shared/tagged_models_unit_specs.rb +72 -0
- data/spec/unit/sourceable_unit_spec.rb +12 -4
- data/spec/unit/step_unit_spec.rb +40 -231
- data/spec/unit/stepped_unit_spec.rb +23 -0
- data/spec/unit/table_unit_spec.rb +27 -89
- data/spec/unit/tag_unit_spec.rb +30 -53
- data/spec/unit/taggable_unit_spec.rb +26 -42
- data/todo.txt +32 -0
- metadata +135 -217
- data/features/analysis/test_manipulation.feature +0 -37
- data/features/modeling/gherkin/background_modeling.feature +0 -65
- data/features/modeling/gherkin/background_output.feature +0 -131
- data/features/modeling/gherkin/directory_modeling.feature +0 -110
- data/features/modeling/gherkin/directory_output.feature +0 -14
- data/features/modeling/gherkin/doc_string_modeling.feature +0 -53
- data/features/modeling/gherkin/doc_string_output.feature +0 -72
- data/features/modeling/gherkin/example_modeling.feature +0 -101
- data/features/modeling/gherkin/example_output.feature +0 -193
- data/features/modeling/gherkin/feature_file_modeling.feature +0 -54
- data/features/modeling/gherkin/feature_file_output.feature +0 -14
- data/features/modeling/gherkin/feature_modeling.feature +0 -154
- data/features/modeling/gherkin/feature_output.feature +0 -245
- data/features/modeling/gherkin/outline_modeling.feature +0 -90
- data/features/modeling/gherkin/outline_output.feature +0 -198
- data/features/modeling/gherkin/row_modeling.feature +0 -68
- data/features/modeling/gherkin/row_output.feature +0 -28
- data/features/modeling/gherkin/scenario_modeling.feature +0 -79
- data/features/modeling/gherkin/scenario_output.feature +0 -148
- data/features/modeling/gherkin/step_modeling.feature +0 -75
- data/features/modeling/gherkin/step_output.feature +0 -53
- data/features/modeling/gherkin/table_modeling.feature +0 -42
- data/features/modeling/gherkin/table_output.feature +0 -43
- data/features/modeling/gherkin/table_row_modeling.feature +0 -57
- data/features/modeling/gherkin/table_row_output.feature +0 -28
- data/features/modeling/gherkin/tag_modeling.feature +0 -48
- data/features/modeling/gherkin/tag_output.feature +0 -17
- data/features/modeling/gherkin3/background_modeling.feature +0 -64
- data/features/modeling/gherkin3/background_output.feature +0 -131
- data/features/modeling/gherkin3/directory_modeling.feature +0 -110
- data/features/modeling/gherkin3/directory_output.feature +0 -14
- data/features/modeling/gherkin3/doc_string_modeling.feature +0 -53
- data/features/modeling/gherkin3/doc_string_output.feature +0 -72
- data/features/modeling/gherkin3/example_modeling.feature +0 -100
- data/features/modeling/gherkin3/example_output.feature +0 -207
- data/features/modeling/gherkin3/feature_file_modeling.feature +0 -54
- data/features/modeling/gherkin3/feature_file_output.feature +0 -14
- data/features/modeling/gherkin3/feature_modeling.feature +0 -155
- data/features/modeling/gherkin3/feature_output.feature +0 -249
- data/features/modeling/gherkin3/outline_modeling.feature +0 -89
- data/features/modeling/gherkin3/outline_output.feature +0 -255
- data/features/modeling/gherkin3/row_modeling.feature +0 -68
- data/features/modeling/gherkin3/row_output.feature +0 -28
- data/features/modeling/gherkin3/scenario_modeling.feature +0 -78
- data/features/modeling/gherkin3/scenario_output.feature +0 -148
- data/features/modeling/gherkin3/step_modeling.feature +0 -75
- data/features/modeling/gherkin3/step_output.feature +0 -53
- data/features/modeling/gherkin3/table_modeling.feature +0 -42
- data/features/modeling/gherkin3/table_output.feature +0 -43
- data/features/modeling/gherkin3/table_row_modeling.feature +0 -57
- data/features/modeling/gherkin3/table_row_output.feature +0 -28
- data/features/modeling/gherkin3/tag_modeling.feature +0 -49
- data/features/modeling/gherkin3/tag_output.feature +0 -17
- data/features/modeling/gherkin4/background_modeling.feature +0 -64
- data/features/modeling/gherkin4/background_output.feature +0 -131
- data/features/modeling/gherkin4/directory_modeling.feature +0 -110
- data/features/modeling/gherkin4/directory_output.feature +0 -14
- data/features/modeling/gherkin4/doc_string_modeling.feature +0 -53
- data/features/modeling/gherkin4/doc_string_output.feature +0 -72
- data/features/modeling/gherkin4/example_modeling.feature +0 -100
- data/features/modeling/gherkin4/example_output.feature +0 -193
- data/features/modeling/gherkin4/feature_file_modeling.feature +0 -54
- data/features/modeling/gherkin4/feature_file_output.feature +0 -14
- data/features/modeling/gherkin4/feature_modeling.feature +0 -153
- data/features/modeling/gherkin4/feature_output.feature +0 -245
- data/features/modeling/gherkin4/outline_modeling.feature +0 -89
- data/features/modeling/gherkin4/outline_output.feature +0 -198
- data/features/modeling/gherkin4/row_modeling.feature +0 -68
- data/features/modeling/gherkin4/row_output.feature +0 -28
- data/features/modeling/gherkin4/scenario_modeling.feature +0 -78
- data/features/modeling/gherkin4/scenario_output.feature +0 -148
- data/features/modeling/gherkin4/step_modeling.feature +0 -75
- data/features/modeling/gherkin4/step_output.feature +0 -53
- data/features/modeling/gherkin4/table_modeling.feature +0 -42
- data/features/modeling/gherkin4/table_output.feature +0 -43
- data/features/modeling/gherkin4/table_row_modeling.feature +0 -57
- data/features/modeling/gherkin4/table_row_output.feature +0 -28
- data/features/modeling/gherkin4/tag_modeling.feature +0 -48
- data/features/modeling/gherkin4/tag_output.feature +0 -17
- data/features/step_definitions/outline_steps.rb +0 -258
- data/features/step_definitions/test_steps.rb +0 -123
- data/lib/cuke_modeler/background.rb +0 -38
- data/lib/cuke_modeler/directory.rb +0 -83
- data/lib/cuke_modeler/doc_string.rb +0 -87
- data/lib/cuke_modeler/example.rb +0 -195
- data/lib/cuke_modeler/feature.rb +0 -147
- data/lib/cuke_modeler/feature_element.rb +0 -73
- data/lib/cuke_modeler/feature_file.rb +0 -77
- data/lib/cuke_modeler/outline.rb +0 -68
- data/lib/cuke_modeler/raw.rb +0 -20
- data/lib/cuke_modeler/row.rb +0 -64
- data/lib/cuke_modeler/scenario.rb +0 -45
- data/lib/cuke_modeler/step.rb +0 -216
- data/lib/cuke_modeler/table.rb +0 -90
- data/lib/cuke_modeler/table_row.rb +0 -64
- data/lib/cuke_modeler/tag.rb +0 -62
- data/lib/cuke_modeler/test_element.rb +0 -79
- data/lib/cuke_modeler/world.rb +0 -113
- data/spec/integration/table_row_integration_spec.rb +0 -76
- data/spec/integration/world_integration_spec.rb +0 -14
- data/spec/unit/containing_element_unit_specs.rb +0 -18
- data/spec/unit/feature_element_unit_spec.rb +0 -19
- data/spec/unit/feature_element_unit_specs.rb +0 -52
- data/spec/unit/nested_element_unit_specs.rb +0 -39
- data/spec/unit/prepopulated_unit_specs.rb +0 -14
- data/spec/unit/raw_element_unit_specs.rb +0 -27
- data/spec/unit/raw_unit_spec.rb +0 -28
- data/spec/unit/sourced_element_unit_specs.rb +0 -18
- data/spec/unit/table_row_unit_spec.rb +0 -102
- data/spec/unit/tagged_element_unit_specs.rb +0 -67
- data/spec/unit/test_element_unit_spec.rb +0 -54
- data/spec/unit/test_element_unit_specs.rb +0 -34
- data/spec/unit/world_unit_spec.rb +0 -140
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Given(/^the models provided by CukeModeler/) do
|
|
2
|
+
@available_model_classes = Array.new.tap do |classes|
|
|
3
|
+
CukeModeler.constants.each do |constant|
|
|
4
|
+
if CukeModeler.const_get(constant).is_a?(Class)
|
|
5
|
+
classes << CukeModeler.const_get(constant) if CukeModeler.const_get(constant).ancestors.include?(CukeModeler::Model)
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
When(/^the model is output as a string$/) do |code_text|
|
|
12
|
+
@output = eval(code_text)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
And(/^a(?:n)? \w+(?: \w+)? model based on that gherkin$/) do |code_text|
|
|
16
|
+
code_text.gsub!('<source_text>', "'#{@source_text}'")
|
|
17
|
+
|
|
18
|
+
eval(code_text)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Given(/^(?:a|the) (?:directory|feature file) is modeled$/) do |code_text|
|
|
22
|
+
code_text.gsub!('<path_to>', @default_file_directory)
|
|
23
|
+
|
|
24
|
+
eval(code_text)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
When(/^the \w+(?: \w+)?'s \w+(?: \w+)? (?:is|are) requested$/) do |code_text|
|
|
28
|
+
@result = eval(code_text)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Given(/^a model for the following background:$/) do |gherkin_text|
|
|
32
|
+
@models ||= []
|
|
33
|
+
@models << CukeModeler::Background.new(gherkin_text)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
Given(/^a model for the following scenario:$/) do |gherkin_text|
|
|
37
|
+
@models ||= []
|
|
38
|
+
@models << CukeModeler::Scenario.new(gherkin_text)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Given(/^a model for the following outline:$/) do |gherkin_text|
|
|
42
|
+
@models ||= []
|
|
43
|
+
@models << CukeModeler::Outline.new(gherkin_text)
|
|
44
|
+
end
|
|
@@ -1,50 +1,28 @@
|
|
|
1
|
-
Given /^
|
|
2
|
-
@test_directory ||= @default_file_directory
|
|
3
|
-
file_name ||= @default_feature_file_name
|
|
4
|
-
|
|
5
|
-
File.open("#{@test_directory}/#{file_name}", 'w') { |file|
|
|
6
|
-
file.write(file_text)
|
|
7
|
-
}
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
When /^the file(?: "([^"]*)")? is read$/ do |file_name|
|
|
11
|
-
@parsed_files ||= []
|
|
12
|
-
@test_directory ||= @default_file_directory
|
|
13
|
-
file_name ||= @default_feature_file_name
|
|
14
|
-
|
|
15
|
-
@parsed_files << CukeModeler::FeatureFile.new("#{@test_directory}/#{file_name}")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
When /^the step definition file "([^"]*)" is read$/ do |file_name|
|
|
19
|
-
@test_directory ||= @default_file_directory
|
|
20
|
-
file_name ||= @default_step_file_name
|
|
21
|
-
|
|
22
|
-
CukeModeler::World.load_step_file("#{@test_directory}/#{file_name}")
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
When /^parameter delimiters of "([^"]*)" and "([^"]*)"$/ do |left_delimiter, right_delimiter|
|
|
26
|
-
CukeModeler::World.left_delimiter = left_delimiter
|
|
27
|
-
CukeModeler::World.right_delimiter = right_delimiter
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
Given /^a directory "([^"]*)"$/ do |directory_name|
|
|
1
|
+
Given /^(?:a|the) directory "([^"]*)"$/ do |directory_name|
|
|
31
2
|
@test_directory = "#{@default_file_directory}/#{directory_name}"
|
|
32
3
|
|
|
33
4
|
FileUtils.mkdir(@test_directory) unless File.exists?(@test_directory)
|
|
34
5
|
end
|
|
35
6
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
7
|
+
And(/^(?:a|the) file "([^"]*)"$/) do |file_name|
|
|
8
|
+
file_path = "#{@default_file_directory}/#{file_name}"
|
|
9
|
+
|
|
10
|
+
# Some versions of Gherkin require feature content to be present in feature files
|
|
11
|
+
if file_name =~ /\.feature/
|
|
12
|
+
File.open(file_path, 'w') { |file|
|
|
13
|
+
file.write('Feature:')
|
|
14
|
+
}
|
|
15
|
+
else
|
|
16
|
+
FileUtils.touch(file_path)
|
|
17
|
+
end
|
|
41
18
|
end
|
|
42
19
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
20
|
+
And(/^the file "([^"]*)":$/) do |file_name, file_text|
|
|
21
|
+
file_path = "#{@default_file_directory}/#{file_name}"
|
|
22
|
+
|
|
23
|
+
File.open(file_path, 'w') { |file| file.write(file_text) }
|
|
24
|
+
end
|
|
46
25
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
26
|
+
Given(/^the following gherkin:$/) do |text|
|
|
27
|
+
@source_text = text
|
|
50
28
|
end
|
|
@@ -1,167 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
test ||= 1
|
|
4
|
-
step ||= 1
|
|
5
|
-
|
|
6
|
-
expected = keyword
|
|
7
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].keyword
|
|
8
|
-
|
|
9
|
-
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? has the following block:$/ do |file, test, step, block|
|
|
13
|
-
file ||= 1
|
|
14
|
-
test ||= 1
|
|
15
|
-
step ||= 1
|
|
16
|
-
|
|
17
|
-
expected = block.raw.flatten.collect do |cell_value|
|
|
18
|
-
if cell_value.start_with? "'"
|
|
19
|
-
cell_value.slice(1..cell_value.length - 2)
|
|
20
|
-
else
|
|
21
|
-
cell_value
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.flatten
|
|
26
|
-
|
|
27
|
-
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? has no block$/ do |file, test, step|
|
|
31
|
-
file ||= 1
|
|
32
|
-
test ||= 1
|
|
33
|
-
step ||= 1
|
|
34
|
-
|
|
35
|
-
expected = nil
|
|
36
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block
|
|
37
|
-
|
|
38
|
-
actual.should == expected
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? text is "([^"]*)"$/ do |file, test, step, text|
|
|
42
|
-
file ||= 1
|
|
43
|
-
test ||= 1
|
|
44
|
-
step ||= 1
|
|
45
|
-
|
|
46
|
-
expected = text
|
|
47
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].base
|
|
48
|
-
|
|
49
|
-
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? arguments are:$/ do |file, test, step, arguments|
|
|
53
|
-
file ||= 1
|
|
54
|
-
test ||= 1
|
|
55
|
-
step ||= 1
|
|
56
|
-
|
|
57
|
-
expected = arguments.raw.flatten
|
|
58
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].arguments
|
|
59
|
-
|
|
60
|
-
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? has no arguments$/ do |file, test, step|
|
|
64
|
-
file ||= 1
|
|
65
|
-
test ||= 1
|
|
66
|
-
step ||= 1
|
|
67
|
-
|
|
68
|
-
expected = []
|
|
69
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].arguments
|
|
70
|
-
|
|
71
|
-
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? has a "([^"]*)"$/ do |file, test, step, type|
|
|
75
|
-
file ||= 1
|
|
76
|
-
test ||= 1
|
|
77
|
-
step ||= 1
|
|
78
|
-
|
|
79
|
-
case type
|
|
80
|
-
when 'doc string'
|
|
81
|
-
expected = CukeModeler::DocString
|
|
82
|
-
when 'table'
|
|
83
|
-
expected = CukeModeler::Table
|
|
84
|
-
else
|
|
85
|
-
raise(ArgumentError, "Unknown block type: #{type}")
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.class
|
|
89
|
-
|
|
90
|
-
actual.should == expected
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? source line is "([^"]*)"$/ do |file, test, step, line_number|
|
|
94
|
-
file ||= 1
|
|
95
|
-
test ||= 1
|
|
96
|
-
step ||= 1
|
|
97
|
-
|
|
98
|
-
expected = line_number.to_i
|
|
99
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].source_line
|
|
100
|
-
|
|
101
|
-
actual.should == expected
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file, test, step|
|
|
105
|
-
file ||= 1
|
|
106
|
-
test ||= 1
|
|
107
|
-
step ||= 1
|
|
108
|
-
|
|
109
|
-
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].raw_element
|
|
110
|
-
|
|
111
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
112
|
-
raw_element.has_key?(:keyword).should be_true
|
|
113
|
-
else
|
|
114
|
-
raw_element.has_key?('keyword').should be_true
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? table row(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, step, row, properties|
|
|
119
|
-
file ||= 1
|
|
120
|
-
test ||= 1
|
|
121
|
-
step ||= 1
|
|
122
|
-
row ||= 1
|
|
123
|
-
|
|
124
|
-
properties = properties.rows_hash
|
|
125
|
-
|
|
126
|
-
properties.each do |property, value|
|
|
127
|
-
expected = value
|
|
128
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements[row - 1].send(property.to_sym).to_s
|
|
129
|
-
|
|
130
|
-
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? table row(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file, test, step, row|
|
|
135
|
-
file ||= 1
|
|
136
|
-
test ||= 1
|
|
137
|
-
step ||= 1
|
|
138
|
-
row ||= 1
|
|
139
|
-
|
|
140
|
-
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements[row - 1].raw_element
|
|
141
|
-
|
|
142
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
143
|
-
raw_element.has_key?(:cells).should be_true
|
|
144
|
-
else
|
|
145
|
-
raw_element.has_key?('cells').should be_true
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? table row(?: "([^"]*)")? cells are as follows:$/ do |file, test, step, row, cells|
|
|
150
|
-
file ||= 1
|
|
151
|
-
test ||= 1
|
|
152
|
-
step ||= 1
|
|
153
|
-
row ||= 1
|
|
154
|
-
|
|
155
|
-
expected = cells.raw.flatten
|
|
156
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements[row - 1].cells
|
|
157
|
-
|
|
158
|
-
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
Given(/^a step element based on the following gherkin:$/) do |step_text|
|
|
162
|
-
@element = CukeModeler::Step.new(step_text)
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
Then(/^the step has convenient output$/) do
|
|
166
|
-
@parsed_files.first.feature.tests.first.steps.first.method(:to_s).owner.should == CukeModeler::Step
|
|
1
|
+
Given(/^a step model based on the following gherkin:$/) do |source_text|
|
|
2
|
+
@model = CukeModeler::Step.new(source_text)
|
|
167
3
|
end
|
|
@@ -1,58 +1 @@
|
|
|
1
|
-
|
|
2
|
-
file ||= 1
|
|
3
|
-
test ||= 1
|
|
4
|
-
step ||= 1
|
|
5
|
-
|
|
6
|
-
expected = contents.raw
|
|
7
|
-
|
|
8
|
-
@parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements.collect { |row| row.cells }.should == expected
|
|
9
|
-
# todo - remove once #contents is no longer supported
|
|
10
|
-
@parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.contents.should == expected
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"]*)") )?table correctly stores its underlying implementation$/ do |file, test, step|
|
|
14
|
-
file ||= 1
|
|
15
|
-
test ||= 1
|
|
16
|
-
step ||= 1
|
|
17
|
-
|
|
18
|
-
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.raw_element
|
|
19
|
-
|
|
20
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
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
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
Given(/^a table row element$/) do
|
|
29
|
-
@element = CukeModeler::TableRow.new
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
When(/^the table row element has no cells$/) do
|
|
33
|
-
@element.cells = []
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
Given(/^a table row element based on the following gherkin:$/) do |row_text|
|
|
37
|
-
@element = CukeModeler::TableRow.new(row_text)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
Then(/^the table row has convenient output$/) do
|
|
41
|
-
@parsed_files.first.feature.tests.first.steps.first.block.row_elements.first.method(:to_s).owner.should == CukeModeler::TableRow
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
Given(/^a table element$/) do
|
|
45
|
-
@element = CukeModeler::Table.new
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
When(/^the table element has no rows$/) do
|
|
49
|
-
@element.row_elements = []
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
Then(/^the table has convenient output$/) do
|
|
53
|
-
@parsed_files.first.feature.tests.first.steps.first.block.method(:to_s).owner.should == CukeModeler::Table
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
Given(/^a table element based on the following gherkin:$/) do |table_text|
|
|
57
|
-
@element = CukeModeler::Table.new(table_text)
|
|
58
|
-
end
|
|
1
|
+
# No steps specific to this type of model
|
|
@@ -1,73 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
5
|
-
raw_element.has_key?(:name).should be_true
|
|
6
|
-
else
|
|
7
|
-
raw_element.has_key?('name').should be_true
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
When(/^the test tag correctly stores its underlying implementation$/) do
|
|
12
|
-
raw_element = @parsed_files.first.feature.tests.first.tag_elements.first.raw_element
|
|
13
|
-
|
|
14
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
15
|
-
raw_element.has_key?(:name).should be_true
|
|
16
|
-
else
|
|
17
|
-
raw_element.has_key?('name').should be_true
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
When(/^the example tag correctly stores its underlying implementation$/) do
|
|
22
|
-
raw_element = @parsed_files.first.feature.tests.first.examples.first.tag_elements.first.raw_element
|
|
23
|
-
|
|
24
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
25
|
-
raw_element.has_key?(:name).should be_true
|
|
26
|
-
else
|
|
27
|
-
raw_element.has_key?('name').should be_true
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
Then(/^the feature tag name is "([^"]*)"$/) do |tag_name|
|
|
32
|
-
tag = @parsed_files.first.feature.tag_elements.first
|
|
33
|
-
|
|
34
|
-
tag.name.should == tag_name
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
When(/^the test tag name is "([^"]*)"$/) do |tag_name|
|
|
38
|
-
tag = @parsed_files.first.feature.tests.first.tag_elements.first
|
|
39
|
-
|
|
40
|
-
tag.name.should == tag_name
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
When(/^the example tag name is "([^"]*)"$/) do |tag_name|
|
|
44
|
-
tag = @parsed_files.first.feature.tests.first.examples.first.tag_elements.first
|
|
45
|
-
|
|
46
|
-
tag.name.should == tag_name
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
Then(/^the feature tag source line "([^"]*)"$/) do |line|
|
|
50
|
-
tag = @parsed_files.first.feature.tag_elements.first
|
|
51
|
-
|
|
52
|
-
tag.source_line.should == line
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
When(/^the test tag source line "([^"]*)"$/) do |line|
|
|
56
|
-
tag = @parsed_files.first.feature.tests.first.tag_elements.first
|
|
57
|
-
|
|
58
|
-
tag.source_line.should == line
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
When(/^the example tag source line "([^"]*)"$/) do |line|
|
|
62
|
-
tag = @parsed_files.first.feature.tests.first.examples.first.tag_elements.first
|
|
63
|
-
|
|
64
|
-
tag.source_line.should == line
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
Then(/^the tag has convenient output$/) do
|
|
68
|
-
@parsed_files.first.feature.tag_elements.first.method(:to_s).owner.should == CukeModeler::Tag
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
Given(/^a tag element based on the following gherkin:$/) do |tag_text|
|
|
72
|
-
@element = CukeModeler::Tag.new(tag_text)
|
|
1
|
+
When(/^all of the \w+'s tags are requested$/) do |code_text|
|
|
2
|
+
@result = eval(code_text)
|
|
73
3
|
end
|
|
@@ -1,9 +1,157 @@
|
|
|
1
|
+
Then(/^all of them can be output as text appropriate to the model type$/) do |code_text|
|
|
2
|
+
@available_model_classes.each do |clazz|
|
|
3
|
+
code_text.gsub!('<model_class>', clazz.to_s)
|
|
4
|
+
|
|
5
|
+
expect(clazz.instance_method(:to_s).owner).to equal(clazz), "#{clazz} does not override #to_s"
|
|
6
|
+
|
|
7
|
+
# Make sure that the example code is valid
|
|
8
|
+
expect { eval(code_text) }.to_not raise_error
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
1
12
|
Then(/^the following text is provided:$/) do |expected_text|
|
|
2
|
-
expected_text.sub!('path_to', @default_file_directory)
|
|
13
|
+
expected_text.sub!('<path_to>', @default_file_directory)
|
|
14
|
+
|
|
15
|
+
expect(@output).to eq(expected_text)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Then(/^all of them can be contained inside of another model$/) do |code_text|
|
|
19
|
+
@available_model_classes.each do |clazz|
|
|
20
|
+
code_text.gsub!('<model_class>', clazz.to_s)
|
|
21
|
+
|
|
22
|
+
expect(clazz.new).to respond_to(:parent_model)
|
|
23
|
+
|
|
24
|
+
# Make sure that the example code is valid
|
|
25
|
+
expect { eval(code_text) }.to_not raise_error
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
And(/^all of them can contain other models$/) do |code_text|
|
|
30
|
+
@available_model_classes.each do |clazz|
|
|
31
|
+
code_text.gsub!('<model_class>', clazz.to_s)
|
|
32
|
+
|
|
33
|
+
expect(clazz.new).to respond_to(:children)
|
|
34
|
+
|
|
35
|
+
# Make sure that the example code is valid
|
|
36
|
+
expect { eval(code_text) }.to_not raise_error
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Then(/^all of them can be created without further context$/) do |code_text|
|
|
41
|
+
@available_model_classes.each do |clazz|
|
|
42
|
+
code_text.gsub!('<model_class>', clazz.to_s)
|
|
43
|
+
|
|
44
|
+
expect { clazz.new }.to_not raise_error
|
|
45
|
+
|
|
46
|
+
# Make sure that the example code is valid
|
|
47
|
+
expect { eval(code_text) }.to_not raise_error
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
Then(/^the model returns "([^"]*)"$/) do |value|
|
|
52
|
+
value.gsub!('path_to', @default_file_directory) if value.is_a?(String)
|
|
53
|
+
|
|
54
|
+
expect(@result).to eq(value)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Then(/^the model returns$/) do |value|
|
|
58
|
+
value.gsub!('path_to', @default_file_directory) if value.is_a?(String)
|
|
59
|
+
|
|
60
|
+
expect(@result).to eq(value)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Then(/^the model returns models for the following feature files:$/) do |file_names|
|
|
64
|
+
file_names = file_names.raw.flatten
|
|
65
|
+
|
|
66
|
+
expect(@result.collect { |file_model| file_model.name }).to match_array(file_names)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
Then(/^the model returns models for the following directories:$/) do |directory_names|
|
|
70
|
+
directory_names = directory_names.raw.flatten
|
|
71
|
+
|
|
72
|
+
expect(@result.collect { |directory_model| directory_model.name }).to match_array(directory_names)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
And(/^the output can be used to make an equivalent model$/) do |code_text|
|
|
76
|
+
@available_model_classes.each do |clazz|
|
|
77
|
+
code_text.gsub!('<model_class>', clazz.to_s)
|
|
78
|
+
|
|
79
|
+
# More specific verification can't be done for this step because every model has a different
|
|
80
|
+
# populated shape and abstract shape isn't enough to be useful input to the model again.
|
|
3
81
|
|
|
4
|
-
|
|
82
|
+
# Make sure that the example code is valid
|
|
83
|
+
expect { eval(code_text) }.to_not raise_error
|
|
84
|
+
end
|
|
5
85
|
end
|
|
6
86
|
|
|
7
|
-
Then(/^the
|
|
8
|
-
|
|
87
|
+
Then(/^all of them provide access to the parsing data that was used to create them$/) do |code_text|
|
|
88
|
+
unparsed_models = [CukeModeler::Model, CukeModeler::FeatureFile, CukeModeler::Directory]
|
|
89
|
+
|
|
90
|
+
@available_model_classes.each do |clazz|
|
|
91
|
+
next if unparsed_models.include?(clazz)
|
|
92
|
+
|
|
93
|
+
expect(clazz.new).to respond_to(:parsing_data)
|
|
94
|
+
|
|
95
|
+
# Make sure that the example code is valid
|
|
96
|
+
code_text.gsub!('<model_class>', clazz.to_s)
|
|
97
|
+
code_text.gsub!('<source_text>', '')
|
|
98
|
+
|
|
99
|
+
expect { eval(code_text) }.to_not raise_error
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
Then(/^the model returns models for the following steps:$/) do |step_names|
|
|
104
|
+
step_names = step_names.raw.flatten
|
|
105
|
+
|
|
106
|
+
expect(@result.collect { |step_model| step_model.text }).to eq(step_names)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
Then(/^the model returns models for the following rows:$/) do |rows|
|
|
110
|
+
rows = rows.raw
|
|
111
|
+
|
|
112
|
+
expect(@result.collect { |row_model| row_model.cells.collect { |cell| cell.value } }).to eq(rows)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
Then(/^the model returns a model for the following feature:$/) do |feature_name|
|
|
116
|
+
feature_name = feature_name.raw.flatten.first
|
|
117
|
+
|
|
118
|
+
expect(@result.name).to eq(feature_name)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
Then(/^the model returns a model for the following table:$/) do |table_rows|
|
|
122
|
+
table_rows = table_rows.raw
|
|
123
|
+
|
|
124
|
+
expect(@result.rows.collect { |row| row.cells.collect { |cell| cell.value } }).to eq(table_rows)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
Then(/^the model returns a model for the following doc string:$/) do |string_text|
|
|
128
|
+
expect(@result.content).to eq(string_text)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
Then(/^the model returns a model for the background "([^"]*)"$/) do |background_name|
|
|
132
|
+
expect(@result.name).to eq(background_name)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
Then(/^the model returns models for the following (?:scenario|outline|tag|example)s:$/) do |model_names|
|
|
136
|
+
model_names = model_names.raw.flatten
|
|
137
|
+
|
|
138
|
+
expect(@result.collect { |model| model.name }).to eq(model_names)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
Then(/^the model returns models for the following cells:$/) do |model_values|
|
|
142
|
+
model_values = model_values.raw.flatten
|
|
143
|
+
|
|
144
|
+
expect(@result.collect { |model| model.value }).to eq(model_values)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
Then(/^all of them are equivalent$/) do
|
|
148
|
+
expect(@results).to_not include(false)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
But(/^none of the models are equivalent with a model for the following scenario:$/) do |gherkin_text|
|
|
152
|
+
model = CukeModeler::Scenario.new(gherkin_text)
|
|
153
|
+
|
|
154
|
+
@models.each do |other_model|
|
|
155
|
+
expect(model == other_model).to_not be true
|
|
156
|
+
end
|
|
9
157
|
end
|