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
data/lib/cuke_modeler/feature.rb
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a Cucumber Feature.
|
|
4
|
-
|
|
5
|
-
class Feature < FeatureElement
|
|
6
|
-
|
|
7
|
-
include Taggable
|
|
8
|
-
include Containing
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# The Background object contained by the Feature
|
|
12
|
-
attr_accessor :background
|
|
13
|
-
|
|
14
|
-
# The TestElement objects contained by the Feature
|
|
15
|
-
attr_accessor :tests
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# Creates a new Feature object and, if *source* is provided, populates the
|
|
19
|
-
# object.
|
|
20
|
-
def initialize(source = nil)
|
|
21
|
-
parsed_feature = process_source(source)
|
|
22
|
-
|
|
23
|
-
super(parsed_feature)
|
|
24
|
-
|
|
25
|
-
@tags = []
|
|
26
|
-
@tag_elements = []
|
|
27
|
-
@tests = []
|
|
28
|
-
|
|
29
|
-
build_feature(parsed_feature) if parsed_feature
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Returns true if the feature contains a background, false otherwise.
|
|
33
|
-
def has_background?
|
|
34
|
-
!@background.nil?
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Returns the scenarios contained in the feature.
|
|
38
|
-
def scenarios
|
|
39
|
-
@tests.select { |test| test.is_a? Scenario }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Returns the outlines contained in the feature.
|
|
43
|
-
def outlines
|
|
44
|
-
@tests.select { |test| test.is_a? Outline }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Returns the number of scenarios contained in the feature.
|
|
48
|
-
def scenario_count
|
|
49
|
-
scenarios.count
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# Returns the number of outlines contained in the feature.
|
|
53
|
-
def outline_count
|
|
54
|
-
outlines.count
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# Returns the number of tests contained in the feature.
|
|
58
|
-
def test_count
|
|
59
|
-
@tests.count
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Returns the number of test cases contained in the feature.
|
|
63
|
-
def test_case_count
|
|
64
|
-
scenario_count + outlines.reduce(0) { |outline_sum, outline|
|
|
65
|
-
outline_sum += outline.examples.reduce(0) { |example_sum, example|
|
|
66
|
-
example_sum += example.rows.count
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# Returns the immediate child elements of the feature (i.e. its Background,
|
|
72
|
-
# Scenario, and Outline objects.
|
|
73
|
-
def contains
|
|
74
|
-
@background ? [@background] + @tests : @tests
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# Returns gherkin representation of the feature.
|
|
79
|
-
def to_s
|
|
80
|
-
text = ''
|
|
81
|
-
|
|
82
|
-
text << tag_output_string + "\n" unless tags.empty?
|
|
83
|
-
text << "Feature:#{name_output_string}"
|
|
84
|
-
text << "\n" + description_output_string unless description_text.empty?
|
|
85
|
-
text << "\n\n" + background_output_string if background
|
|
86
|
-
text << "\n\n" + tests_output_string unless tests.empty?
|
|
87
|
-
|
|
88
|
-
text
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
private
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def process_source(source)
|
|
96
|
-
case
|
|
97
|
-
when source.is_a?(String)
|
|
98
|
-
parse_feature(source)
|
|
99
|
-
else
|
|
100
|
-
source
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def parse_feature(source_text)
|
|
105
|
-
parsed_file = Parsing::parse_text(source_text, 'cuke_modeler_stand_alone_feature.feature')
|
|
106
|
-
|
|
107
|
-
parsed_file.first
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def build_feature(parsed_feature)
|
|
111
|
-
populate_element_tags(parsed_feature)
|
|
112
|
-
populate_feature_elements(parsed_feature)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def populate_feature_elements(parsed_feature)
|
|
116
|
-
elements = parsed_feature['elements']
|
|
117
|
-
|
|
118
|
-
if elements
|
|
119
|
-
elements.each do |element|
|
|
120
|
-
case element['keyword']
|
|
121
|
-
when 'Scenario'
|
|
122
|
-
@tests << build_child_element(Scenario, element)
|
|
123
|
-
when 'Scenario Outline'
|
|
124
|
-
@tests << build_child_element(Outline, element)
|
|
125
|
-
when 'Background'
|
|
126
|
-
@background = build_child_element(Background, element)
|
|
127
|
-
else
|
|
128
|
-
raise(ArgumentError, "Unknown keyword: #{element['keyword']}")
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def background_output_string
|
|
135
|
-
test_element_output_string(background)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def tests_output_string
|
|
139
|
-
tests.collect { |test| test_element_output_string(test) }.join("\n\n")
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def test_element_output_string(test_element)
|
|
143
|
-
test_element.to_s.split("\n").collect { |line| line.empty? ? '' : " #{line}" }.join("\n")
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
end
|
|
147
|
-
end
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling an basic element of a feature.
|
|
4
|
-
|
|
5
|
-
class FeatureElement
|
|
6
|
-
|
|
7
|
-
include Sourceable
|
|
8
|
-
include Raw
|
|
9
|
-
include Nested
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# The name of the FeatureElement
|
|
13
|
-
attr_accessor :name
|
|
14
|
-
|
|
15
|
-
# Deprecated
|
|
16
|
-
#
|
|
17
|
-
# The description of the FeatureElement
|
|
18
|
-
attr_accessor :description
|
|
19
|
-
|
|
20
|
-
# The description of the FeatureElement
|
|
21
|
-
attr_accessor :description_text
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# Creates a new FeatureElement object and, if *parsed_element* is provided,
|
|
25
|
-
# populates the object.
|
|
26
|
-
def initialize(parsed_element = nil)
|
|
27
|
-
@name = ''
|
|
28
|
-
@description = []
|
|
29
|
-
@description_text = ''
|
|
30
|
-
|
|
31
|
-
build_feature_element(parsed_element) if parsed_element
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def build_feature_element(parsed_element)
|
|
39
|
-
populate_feature_element_name(parsed_element)
|
|
40
|
-
populate_feature_element_description(parsed_element)
|
|
41
|
-
populate_element_source_line(parsed_element)
|
|
42
|
-
populate_raw_element(parsed_element)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def populate_feature_element_name(parsed_element)
|
|
46
|
-
@name = parsed_element['name']
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def populate_feature_element_description(parsed_element)
|
|
50
|
-
@description_text = parsed_element['description']
|
|
51
|
-
@description = parsed_element['description'].split("\n").collect { |line| line.strip }
|
|
52
|
-
@description.delete('')
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def name_output_string
|
|
56
|
-
name.empty? ? '' : " #{name}"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def description_output_string
|
|
60
|
-
text = ''
|
|
61
|
-
|
|
62
|
-
unless description_text.empty?
|
|
63
|
-
description_lines = description_text.split("\n")
|
|
64
|
-
|
|
65
|
-
text << " \n" if description_lines.first =~ /\S/
|
|
66
|
-
text << description_lines.collect { |line| " #{line}" }.join("\n")
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
text
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a Cucumber .feature file.
|
|
4
|
-
|
|
5
|
-
class FeatureFile
|
|
6
|
-
|
|
7
|
-
include Containing
|
|
8
|
-
include Nested
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# The Feature objects contained by the FeatureFile
|
|
12
|
-
attr_accessor :features
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# Creates a new FeatureFile object and, if *file_parsed* is provided,
|
|
16
|
-
# populates the object.
|
|
17
|
-
def initialize(file = nil)
|
|
18
|
-
@file = file
|
|
19
|
-
@features = []
|
|
20
|
-
|
|
21
|
-
if file
|
|
22
|
-
raise(ArgumentError, "Unknown file: #{file.inspect}") unless File.exists?(file)
|
|
23
|
-
|
|
24
|
-
parsed_file = parse_file(file)
|
|
25
|
-
|
|
26
|
-
build_file(parsed_file)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Returns the name of the file.
|
|
31
|
-
def name
|
|
32
|
-
File.basename(@file.gsub('\\', '/'))
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Returns the path of the file.
|
|
36
|
-
def path
|
|
37
|
-
@file
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Returns the immediate child elements of the file(i.e. its Feature object).
|
|
41
|
-
def contains
|
|
42
|
-
@features
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# Returns the number of features contained in the file.
|
|
46
|
-
def feature_count
|
|
47
|
-
@features.count
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Returns the Feature object contained by the FeatureFile.
|
|
51
|
-
def feature
|
|
52
|
-
@features.first
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Returns the path of the feature file.
|
|
56
|
-
def to_s
|
|
57
|
-
path.to_s
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
private
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def parse_file(file_to_parse)
|
|
65
|
-
source_text = IO.read(file_to_parse)
|
|
66
|
-
|
|
67
|
-
Parsing::parse_text(source_text, file_to_parse)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def build_file(parsed_file)
|
|
71
|
-
unless parsed_file.empty?
|
|
72
|
-
@features << build_child_element(Feature, parsed_file.first)
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
end
|
|
77
|
-
end
|
data/lib/cuke_modeler/outline.rb
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a Cucumber Scenario Outline.
|
|
4
|
-
|
|
5
|
-
class Outline < TestElement
|
|
6
|
-
|
|
7
|
-
include Taggable
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# The Example objects contained by the Outline
|
|
11
|
-
attr_accessor :examples
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# Creates a new Outline object and, if *source* is provided, populates the
|
|
15
|
-
# object.
|
|
16
|
-
def initialize(source = nil)
|
|
17
|
-
parsed_outline = process_source(source, 'cuke_modeler_stand_alone_outline.feature')
|
|
18
|
-
|
|
19
|
-
super(parsed_outline)
|
|
20
|
-
|
|
21
|
-
@tags = []
|
|
22
|
-
@tag_elements = []
|
|
23
|
-
@examples = []
|
|
24
|
-
|
|
25
|
-
build_outline(parsed_outline) if parsed_outline
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Returns the immediate child elements of the outline (i.e. its Example
|
|
29
|
-
# objects.
|
|
30
|
-
def contains
|
|
31
|
-
@examples + @steps
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Returns a gherkin representation of the outline.
|
|
35
|
-
def to_s
|
|
36
|
-
text = ''
|
|
37
|
-
|
|
38
|
-
text << tag_output_string + "\n" unless tags.empty?
|
|
39
|
-
text << "Scenario Outline:#{name_output_string}"
|
|
40
|
-
text << "\n" + description_output_string unless description_text.empty?
|
|
41
|
-
text << "\n" unless steps.empty? || description_text.empty?
|
|
42
|
-
text << "\n" + steps_output_string unless steps.empty?
|
|
43
|
-
text << "\n\n" + examples_output_string unless examples.empty?
|
|
44
|
-
|
|
45
|
-
text
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def build_outline(parsed_outline)
|
|
53
|
-
populate_element_tags(parsed_outline)
|
|
54
|
-
populate_outline_examples(parsed_outline['examples']) if parsed_outline['examples']
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def populate_outline_examples(parsed_examples)
|
|
58
|
-
parsed_examples.each do |example|
|
|
59
|
-
@examples << build_child_element(Example, example)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def examples_output_string
|
|
64
|
-
examples.empty? ? '' : examples.collect { |example| example.to_s }.join("\n\n")
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
end
|
|
68
|
-
end
|
data/lib/cuke_modeler/raw.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A mix-in module containing methods used by elements that store their
|
|
4
|
-
# underlying implementation
|
|
5
|
-
|
|
6
|
-
module Raw
|
|
7
|
-
|
|
8
|
-
# The raw representation of the element (i.e. the output of the gherkin gem)
|
|
9
|
-
attr_accessor :raw_element
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def populate_raw_element(parsed_element)
|
|
16
|
-
@raw_element = parsed_element['cuke_modeler_raw_adapter_output']
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
end
|
data/lib/cuke_modeler/row.rb
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a Cucumber Examples table row.
|
|
4
|
-
|
|
5
|
-
class Row
|
|
6
|
-
|
|
7
|
-
include Sourceable
|
|
8
|
-
include Raw
|
|
9
|
-
include Nested
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# The cells that make up the row
|
|
13
|
-
attr_accessor :cells
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# Creates a new Row object and, if *source* is provided, populates
|
|
17
|
-
# the object.
|
|
18
|
-
def initialize(source = nil)
|
|
19
|
-
parsed_row = process_source(source)
|
|
20
|
-
|
|
21
|
-
@cells = []
|
|
22
|
-
|
|
23
|
-
build_row(parsed_row) if parsed_row
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Returns a gherkin representation of the row.
|
|
27
|
-
def to_s
|
|
28
|
-
"| #{cells.join(' | ')} |"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def process_source(source)
|
|
36
|
-
case
|
|
37
|
-
when source.is_a?(String)
|
|
38
|
-
parse_row(source)
|
|
39
|
-
else
|
|
40
|
-
source
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def parse_row(source_text)
|
|
45
|
-
base_file_string = "Feature: Fake feature to parse\nScenario Outline:\n* fake step\nExamples: fake examples\n#{source_text}\n"
|
|
46
|
-
source_text = base_file_string + source_text
|
|
47
|
-
|
|
48
|
-
parsed_file = Parsing::parse_text(source_text, 'cuke_modeler_stand_alone_row.feature')
|
|
49
|
-
|
|
50
|
-
parsed_file.first['elements'].first['examples'].first['rows'].last
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def build_row(parsed_row)
|
|
54
|
-
populate_element_source_line(parsed_row)
|
|
55
|
-
populate_row_cells(parsed_row)
|
|
56
|
-
populate_raw_element(parsed_row)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def populate_row_cells(parsed_row)
|
|
60
|
-
@cells = parsed_row['cells']
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
end
|
|
64
|
-
end
|