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
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, properties|
|
|
2
|
-
file ||= 1
|
|
3
|
-
test ||= 1
|
|
4
|
-
|
|
5
|
-
properties = properties.rows_hash
|
|
6
|
-
|
|
7
|
-
properties.each do |property, value|
|
|
8
|
-
|
|
9
|
-
actual = @parsed_files[file - 1].feature.tests[test - 1].send(property.to_sym).to_s
|
|
10
|
-
expected = value
|
|
11
|
-
|
|
12
|
-
assert(actual == expected, "Expected #{property} to be: #{expected}\n but was: #{actual}")
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? has the following description:$/ do |file, test, text|
|
|
17
|
-
file ||= 1
|
|
18
|
-
test ||= 1
|
|
19
|
-
|
|
20
|
-
new_description = @parsed_files[file - 1].feature.tests[test - 1].description_text
|
|
21
|
-
old_description = @parsed_files[file - 1].feature.tests[test - 1].description
|
|
22
|
-
|
|
23
|
-
new_description.should == text
|
|
24
|
-
old_description.should == remove_whitespace(text)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? steps are as follows:$/ do |file, test, steps|
|
|
28
|
-
file ||= 1
|
|
29
|
-
test ||= 1
|
|
30
|
-
|
|
31
|
-
steps = steps.raw.flatten.collect do |step|
|
|
32
|
-
if step.start_with? "'"
|
|
33
|
-
step.slice(1..step.length - 2)
|
|
34
|
-
else
|
|
35
|
-
step
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
actual_steps = Array.new.tap do |steps|
|
|
40
|
-
@parsed_files[file - 1].feature.tests[test - 1].steps.each do |step|
|
|
41
|
-
steps << step.base
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
expect(actual_steps.flatten).to eq(steps)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the following tags:$/ do |file, test, expected_tags|
|
|
49
|
-
file ||= 1
|
|
50
|
-
test ||= 1
|
|
51
|
-
|
|
52
|
-
expected_tags = expected_tags.raw.flatten
|
|
53
|
-
|
|
54
|
-
@parsed_files[file - 1].feature.tests[test - 1].tags.should == expected_tags
|
|
55
|
-
@parsed_files[file - 1].feature.tests[test - 1].tag_elements.collect { |tag| tag.name }.should == expected_tags
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the following applied tags:$/ do |file, test, expected_tags|
|
|
59
|
-
file ||= 1
|
|
60
|
-
test ||= 1
|
|
61
|
-
|
|
62
|
-
expected_tags = expected_tags.raw.flatten
|
|
63
|
-
|
|
64
|
-
@parsed_files[file - 1].feature.tests[test - 1].applied_tags.should == expected_tags
|
|
65
|
-
@parsed_files[file - 1].feature.tests[test - 1].applied_tag_elements.collect { |tag| tag.name }.should == expected_tags
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step "([^"]*)" has the following block:$/ do |file, test, step, block|
|
|
69
|
-
file ||= 1
|
|
70
|
-
test ||= 1
|
|
71
|
-
|
|
72
|
-
block = block.raw.flatten.collect do |line|
|
|
73
|
-
if line.start_with? "'"
|
|
74
|
-
line.slice(1..line.length - 2)
|
|
75
|
-
else
|
|
76
|
-
line
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
assert @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block == block
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is equal to test "([^"]*)"$/ do |file, first_test, second_test|
|
|
84
|
-
file ||= 1
|
|
85
|
-
first_test ||= 1
|
|
86
|
-
|
|
87
|
-
expected = true
|
|
88
|
-
actual = @parsed_files[file - 1].feature.tests[first_test - 1] == @parsed_files[file - 1].feature.tests[second_test - 1]
|
|
89
|
-
|
|
90
|
-
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is not equal to test "([^"]*)"$/ do |file, first_test, second_test|
|
|
94
|
-
file ||= 1
|
|
95
|
-
first_test ||= 1
|
|
96
|
-
|
|
97
|
-
assert @parsed_files[file - 1].feature.tests[first_test - 1] != @parsed_files[file - 1].feature.tests[second_test - 1]
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file, test|
|
|
101
|
-
file ||= 1
|
|
102
|
-
test ||= 1
|
|
103
|
-
|
|
104
|
-
raw_element = @parsed_files[file - 1].feature.tests[test - 1].raw_element
|
|
105
|
-
|
|
106
|
-
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
|
107
|
-
expected = ['Scenario', 'Scenario Outline']
|
|
108
|
-
actual = raw_element[:keyword]
|
|
109
|
-
else
|
|
110
|
-
expected = ['Scenario', 'Scenario Outline']
|
|
111
|
-
actual = raw_element['keyword']
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
expected.include?(actual).should be_true
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
Then(/^the scenario has convenient output$/) do
|
|
118
|
-
@parsed_files.first.feature.tests.first.method(:to_s).owner.should == CukeModeler::Scenario
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
Given(/^a scenario element based on the following gherkin:$/) do |scenario_text|
|
|
122
|
-
@element = CukeModeler::Scenario.new(scenario_text)
|
|
123
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a Cucumber feature's Background.
|
|
4
|
-
|
|
5
|
-
class Background < TestElement
|
|
6
|
-
|
|
7
|
-
# Creates a new Background object and, if *source* is provided, populates
|
|
8
|
-
# the object.
|
|
9
|
-
def initialize(source = nil)
|
|
10
|
-
parsed_background = process_source(source, 'cuke_modeler_stand_alone_background.feature')
|
|
11
|
-
|
|
12
|
-
super(parsed_background)
|
|
13
|
-
|
|
14
|
-
build_background(parsed_background) if parsed_background
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Returns gherkin representation of the background.
|
|
18
|
-
def to_s
|
|
19
|
-
text = ''
|
|
20
|
-
|
|
21
|
-
text << "Background:#{name_output_string}"
|
|
22
|
-
text << "\n" + description_output_string unless description_text.empty?
|
|
23
|
-
text << "\n" unless steps.empty? || description_text.empty?
|
|
24
|
-
text << "\n" + steps_output_string unless steps.empty?
|
|
25
|
-
|
|
26
|
-
text
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def build_background(parsed_background)
|
|
34
|
-
# Just a stub in case something specific needs to be done
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a directory containing .feature files.
|
|
4
|
-
|
|
5
|
-
class Directory
|
|
6
|
-
|
|
7
|
-
include Containing
|
|
8
|
-
include Nested
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# The FeatureFile objects contained by the Directory
|
|
12
|
-
attr_accessor :feature_files
|
|
13
|
-
|
|
14
|
-
# The Directory objects contained by the Directory
|
|
15
|
-
attr_accessor :directories
|
|
16
|
-
|
|
17
|
-
# The file path of the Directory
|
|
18
|
-
attr_accessor :path
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# Creates a new Directory object and, if *directory_parsed* is provided,
|
|
22
|
-
# populates the object.
|
|
23
|
-
def initialize(directory_parsed = nil)
|
|
24
|
-
@path = directory_parsed
|
|
25
|
-
@feature_files = []
|
|
26
|
-
@directories = []
|
|
27
|
-
|
|
28
|
-
if directory_parsed
|
|
29
|
-
raise(ArgumentError, "Unknown directory: #{directory_parsed.inspect}") unless File.exists?(directory_parsed)
|
|
30
|
-
build_directory
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Returns the name of the directory.
|
|
35
|
-
def name
|
|
36
|
-
File.basename(@path.gsub('\\', '/')) if @path
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Returns the number of sub-directories contained in the directory.
|
|
40
|
-
def directory_count
|
|
41
|
-
@directories.count
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Returns the number of features files contained in the directory.
|
|
45
|
-
def feature_file_count
|
|
46
|
-
@feature_files.count
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Returns the immediate child elements of the directory (i.e. its Directory
|
|
50
|
-
# and FeatureFile objects).
|
|
51
|
-
def contains
|
|
52
|
-
@feature_files + @directories
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Returns the path of the directory.
|
|
56
|
-
def to_s
|
|
57
|
-
path.to_s
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
private
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def build_directory
|
|
65
|
-
entries = Dir.entries(@path)
|
|
66
|
-
entries.delete '.'
|
|
67
|
-
entries.delete '..'
|
|
68
|
-
|
|
69
|
-
entries.each do |entry|
|
|
70
|
-
entry = "#{@path}/#{entry}"
|
|
71
|
-
|
|
72
|
-
case
|
|
73
|
-
when File.directory?(entry)
|
|
74
|
-
@directories << build_child_element(Directory, entry)
|
|
75
|
-
when entry =~ /\.feature$/
|
|
76
|
-
@feature_files << build_child_element(FeatureFile, entry)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling the Doc String of a Step.
|
|
4
|
-
|
|
5
|
-
class DocString
|
|
6
|
-
|
|
7
|
-
include Raw
|
|
8
|
-
include Nested
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# The content type associated with the doc string
|
|
12
|
-
attr_accessor :content_type
|
|
13
|
-
|
|
14
|
-
# Deprecated
|
|
15
|
-
#
|
|
16
|
-
# The contents of the doc string
|
|
17
|
-
attr_accessor :contents
|
|
18
|
-
|
|
19
|
-
# The contents of the doc string
|
|
20
|
-
attr_accessor :contents_text
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# Creates a new DocString object and, if *source* is provided, populates
|
|
24
|
-
# the object.
|
|
25
|
-
def initialize(source = nil)
|
|
26
|
-
@contents = []
|
|
27
|
-
@contents_text = ''
|
|
28
|
-
|
|
29
|
-
parsed_doc_string = process_source(source)
|
|
30
|
-
|
|
31
|
-
build_doc_string(parsed_doc_string) if parsed_doc_string
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Returns a gherkin representation of the doc string.
|
|
35
|
-
def to_s
|
|
36
|
-
text = "\"\"\"#{content_type_output_string}\n"
|
|
37
|
-
text << contents_output_string
|
|
38
|
-
text << '"""'
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def process_source(source)
|
|
46
|
-
case
|
|
47
|
-
when source.is_a?(String)
|
|
48
|
-
parse_doc_string(source)
|
|
49
|
-
else
|
|
50
|
-
source
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def parse_doc_string(source_text)
|
|
55
|
-
base_file_string = "Feature:\nScenario:\n* step\n"
|
|
56
|
-
source_text = base_file_string + source_text
|
|
57
|
-
|
|
58
|
-
parsed_file = Parsing::parse_text(source_text, 'cuke_modeler_stand_alone_doc_string.feature')
|
|
59
|
-
|
|
60
|
-
parsed_file.first['elements'].first['steps'].first['doc_string']
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def build_doc_string(doc_string)
|
|
64
|
-
populate_content_type(doc_string)
|
|
65
|
-
populate_contents(doc_string)
|
|
66
|
-
populate_raw_element(doc_string)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def populate_content_type(doc_string)
|
|
70
|
-
@content_type = doc_string['content_type'] == "" ? nil : doc_string['content_type']
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def populate_contents(doc_string)
|
|
74
|
-
@contents = doc_string['value'].split($/, -1)
|
|
75
|
-
@contents_text = doc_string['value']
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def content_type_output_string
|
|
79
|
-
content_type ? " #{content_type}" : ''
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def contents_output_string
|
|
83
|
-
contents_text.empty? ? '' : contents_text.gsub('"""', '\"\"\"') + "\n"
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
end
|
data/lib/cuke_modeler/example.rb
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a Cucumber Examples table.
|
|
4
|
-
|
|
5
|
-
class Example < FeatureElement
|
|
6
|
-
|
|
7
|
-
include Taggable
|
|
8
|
-
include Containing
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# The argument rows in the example table
|
|
12
|
-
#
|
|
13
|
-
# todo - Make this a read only method that derives the rows from
|
|
14
|
-
# the row elements
|
|
15
|
-
attr_accessor :rows
|
|
16
|
-
|
|
17
|
-
# The parameters for the example table
|
|
18
|
-
#
|
|
19
|
-
# todo - Make this a read only method that derives the parameters from
|
|
20
|
-
# the row elements
|
|
21
|
-
attr_accessor :parameters
|
|
22
|
-
|
|
23
|
-
# The row elements in the example table
|
|
24
|
-
attr_accessor :row_elements
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# Creates a new Example object and, if *source* is provided,
|
|
28
|
-
# populates the object.
|
|
29
|
-
def initialize(source = nil)
|
|
30
|
-
parsed_example = process_source(source)
|
|
31
|
-
|
|
32
|
-
super(parsed_example)
|
|
33
|
-
|
|
34
|
-
@tags = []
|
|
35
|
-
@tag_elements = []
|
|
36
|
-
@rows = []
|
|
37
|
-
@parameters = []
|
|
38
|
-
@row_elements = []
|
|
39
|
-
|
|
40
|
-
build_example(parsed_example) if parsed_example
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Adds a row to the example table. The row can be given as a Hash of
|
|
44
|
-
# parameters and their corresponding values or as an Array of values which
|
|
45
|
-
# will be assigned in order.
|
|
46
|
-
def add_row(row)
|
|
47
|
-
raise('Cannot add a row. No parameters have been set.') if @parameters.empty?
|
|
48
|
-
|
|
49
|
-
# A quick 'deep clone' so that the input isn't modified
|
|
50
|
-
row = Marshal::load(Marshal.dump(row))
|
|
51
|
-
|
|
52
|
-
case
|
|
53
|
-
when row.is_a?(Array)
|
|
54
|
-
# 'stringify' input
|
|
55
|
-
row.collect! { |value| value.to_s }
|
|
56
|
-
|
|
57
|
-
@rows << Hash[@parameters.zip(row.collect { |value| value.strip })]
|
|
58
|
-
@row_elements << Row.new("|#{row.join('|')}|")
|
|
59
|
-
when row.is_a?(Hash)
|
|
60
|
-
# 'stringify' input
|
|
61
|
-
row = row.inject({}) { |hash, (key, value)| hash[key.to_s] = value.to_s; hash }
|
|
62
|
-
|
|
63
|
-
@rows << row.each_value { |value| value.strip! }
|
|
64
|
-
@row_elements << Row.new("|#{ordered_row_values(row).join('|')}|")
|
|
65
|
-
else
|
|
66
|
-
raise(ArgumentError, "Can only add row from a Hash or an Array but received #{row.class}")
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Removes a row from the example table. The row can be given as a Hash of
|
|
71
|
-
# parameters and their corresponding values or as an Array of values
|
|
72
|
-
# which will be assigned in order.
|
|
73
|
-
def remove_row(row)
|
|
74
|
-
case
|
|
75
|
-
when row.is_a?(Array)
|
|
76
|
-
location = @rows.index { |row_hash| row_hash.values_at(*@parameters) == row.collect { |value| value.strip } }
|
|
77
|
-
when row.is_a?(Hash)
|
|
78
|
-
location = @rows.index { |row_hash| row_hash == row.each_value { |value| value.strip! } }
|
|
79
|
-
else
|
|
80
|
-
raise(ArgumentError, "Can only remove row from a Hash or an Array but received #{row.class}")
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
#todo - remove once Hash rows are no longer supported
|
|
84
|
-
@rows.delete_at(location) if location
|
|
85
|
-
@row_elements.delete_at(location + 1) if location
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# Returns the immediate child elements of the element.
|
|
89
|
-
def contains
|
|
90
|
-
@row_elements
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Returns a gherkin representation of the example.
|
|
94
|
-
def to_s
|
|
95
|
-
text = ''
|
|
96
|
-
|
|
97
|
-
text << tag_output_string + "\n" unless tags.empty?
|
|
98
|
-
text << "Examples:#{name_output_string}"
|
|
99
|
-
text << "\n" + description_output_string unless description_text.empty?
|
|
100
|
-
text << "\n" unless description_text.empty?
|
|
101
|
-
text << "\n" + parameters_output_string
|
|
102
|
-
text << "\n" + rows_output_string unless rows.empty?
|
|
103
|
-
|
|
104
|
-
text
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
private
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def process_source(source)
|
|
112
|
-
case
|
|
113
|
-
when source.is_a?(String)
|
|
114
|
-
parse_example(source)
|
|
115
|
-
else
|
|
116
|
-
source
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def parse_example(source_text)
|
|
121
|
-
base_file_string = "Feature: Fake feature to parse\nScenario Outline:\n* fake step\n"
|
|
122
|
-
source_text = base_file_string + source_text
|
|
123
|
-
|
|
124
|
-
parsed_file = Parsing::parse_text(source_text, 'cuke_modeler_stand_alone_example.feature')
|
|
125
|
-
|
|
126
|
-
parsed_file.first['elements'].first['examples'].first
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def build_example(parsed_example)
|
|
130
|
-
populate_element_tags(parsed_example)
|
|
131
|
-
populate_example_row_elements(parsed_example)
|
|
132
|
-
populate_example_parameters
|
|
133
|
-
populate_example_rows
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def populate_example_parameters
|
|
137
|
-
@parameters = @row_elements.first.cells unless @row_elements.empty?
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def populate_example_rows
|
|
141
|
-
@row_elements.each do |row|
|
|
142
|
-
@rows << Hash[@parameters.zip(row.cells)]
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
@rows.shift
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def populate_example_row_elements(parsed_example)
|
|
149
|
-
parsed_example['rows'].each do |row|
|
|
150
|
-
@row_elements << build_child_element(Row, row)
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
def determine_buffer_size(index)
|
|
155
|
-
row_elements.collect { |row| row.cells[index].length }.max || 0
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def parameters_output_string
|
|
159
|
-
text = ''
|
|
160
|
-
|
|
161
|
-
unless parameters.empty?
|
|
162
|
-
text << " |"
|
|
163
|
-
parameters.count.times { |index| text << " #{string_for(parameters, index)} |" }
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
text
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
def rows_output_string
|
|
170
|
-
text = ''
|
|
171
|
-
|
|
172
|
-
unless rows.empty?
|
|
173
|
-
|
|
174
|
-
rows.each do |row|
|
|
175
|
-
text << " |"
|
|
176
|
-
row.values.count.times { |index| text << " #{string_for(ordered_row_values(row), index)} |" }
|
|
177
|
-
text << "\n"
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
text.chomp!
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
text
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def string_for(cells, index)
|
|
187
|
-
cells[index] ? cells[index].ljust(determine_buffer_size(index)) : ''
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def ordered_row_values(row_hash)
|
|
191
|
-
@parameters.collect { |parameter| row_hash[parameter] }
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
end
|
|
195
|
-
end
|