cucumber_analytics 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/History.rdoc +16 -0
- data/README.rdoc +5 -3
- data/Rakefile +7 -2
- data/cucumber_analytics.gemspec +7 -5
- data/features/analysis/step_collection.feature +44 -45
- data/features/modeling/background_modeling.feature +14 -144
- data/features/modeling/directory_modeling.feature +3 -2
- data/features/modeling/doc_string_modeling.feature +46 -0
- data/features/modeling/example_modeling.feature +13 -34
- data/features/modeling/feature_file_modeling.feature +3 -2
- data/features/modeling/feature_modeling.feature +18 -80
- data/features/modeling/outline_modeling.feature +25 -164
- data/features/modeling/scenario_modeling.feature +17 -144
- data/features/modeling/step_modeling.feature +68 -0
- data/features/modeling/table_modeling.feature +41 -0
- data/features/step_definitions/background_steps.rb +12 -11
- data/features/step_definitions/directory_steps.rb +6 -3
- data/features/step_definitions/doc_string_steps.rb +50 -0
- data/features/step_definitions/{file_steps.rb → feature_file_steps.rb} +8 -2
- data/features/step_definitions/feature_steps.rb +8 -4
- data/features/step_definitions/outline_steps.rb +12 -6
- data/features/step_definitions/setup_steps.rb +2 -2
- data/features/step_definitions/spec_steps.rb +6 -3
- data/features/step_definitions/step_steps.rb +91 -0
- data/features/step_definitions/table_steps.rb +10 -0
- data/features/step_definitions/test_steps.rb +6 -10
- data/features/step_definitions/world_steps.rb +28 -19
- data/features/support/env.rb +0 -2
- data/lib/cucumber_analytics/background.rb +16 -0
- data/lib/cucumber_analytics/containing.rb +18 -0
- data/lib/cucumber_analytics/directory.rb +83 -0
- data/lib/cucumber_analytics/doc_string.rb +55 -0
- data/lib/cucumber_analytics/example.rb +100 -0
- data/lib/cucumber_analytics/feature.rb +120 -0
- data/lib/cucumber_analytics/feature_element.rb +22 -40
- data/lib/cucumber_analytics/feature_file.rb +74 -0
- data/lib/cucumber_analytics/outline.rb +49 -0
- data/lib/cucumber_analytics/parsing.rb +30 -0
- data/lib/cucumber_analytics/scenario.rb +31 -0
- data/lib/cucumber_analytics/step.rb +142 -32
- data/lib/cucumber_analytics/table.rb +51 -0
- data/lib/cucumber_analytics/taggable.rb +35 -0
- data/lib/cucumber_analytics/test_element.rb +36 -91
- data/lib/cucumber_analytics/version.rb +1 -1
- data/lib/cucumber_analytics/world.rb +109 -153
- data/lib/cucumber_analytics.rb +12 -8
- data/spec/integration/background_integration_spec.rb +18 -0
- data/spec/integration/directory_integration_spec.rb +24 -0
- data/spec/{feature_spec.rb → integration/feature_file_integration_spec.rb} +5 -5
- data/spec/integration/feature_integration_spec.rb +86 -0
- data/spec/integration/outline_integration_spec.rb +22 -0
- data/spec/integration/scenario_integration_spec.rb +18 -0
- data/spec/integration/step_integration_spec.rb +116 -0
- data/spec/integration/world_integration_spec.rb +40 -0
- data/spec/spec_helper.rb +7 -3
- data/spec/unit/background_unit_spec.rb +22 -0
- data/spec/unit/bare_bones_unit_specs.rb +13 -0
- data/spec/unit/containing_element_unit_specs.rb +17 -0
- data/spec/unit/directory_unit_spec.rb +91 -0
- data/spec/unit/doc_string_unit_spec.rb +65 -0
- data/spec/unit/example_unit_spec.rb +171 -0
- data/spec/unit/feature_element_unit_spec.rb +19 -0
- data/spec/unit/feature_element_unit_specs.rb +39 -0
- data/spec/unit/feature_file_unit_spec.rb +82 -0
- data/spec/unit/feature_unit_spec.rb +81 -0
- data/spec/unit/nested_element_unit_specs.rb +24 -0
- data/spec/unit/outline_unit_spec.rb +56 -0
- data/spec/unit/parsing_unit_spec.rb +21 -0
- data/spec/unit/prepopulated_unit_specs.rb +13 -0
- data/spec/unit/scenario_unit_spec.rb +36 -0
- data/spec/unit/step_unit_spec.rb +231 -0
- data/spec/unit/table_unit_spec.rb +52 -0
- data/spec/unit/taggable_unit_spec.rb +63 -0
- data/spec/unit/tagged_element_unit_specs.rb +48 -0
- data/spec/unit/test_element_unit_spec.rb +40 -0
- data/spec/unit/test_element_unit_specs.rb +31 -0
- data/spec/unit/world_unit_spec.rb +167 -0
- metadata +106 -41
- data/lib/cucumber_analytics/logging.rb +0 -28
- data/lib/cucumber_analytics/outline_example.rb +0 -110
- data/lib/cucumber_analytics/parsed_background.rb +0 -45
- data/lib/cucumber_analytics/parsed_directory.rb +0 -78
- data/lib/cucumber_analytics/parsed_feature.rb +0 -97
- data/lib/cucumber_analytics/parsed_file.rb +0 -199
- data/lib/cucumber_analytics/parsed_scenario.rb +0 -67
- data/lib/cucumber_analytics/parsed_scenario_outline.rb +0 -122
- data/spec/background_spec.rb +0 -23
- data/spec/directory_spec.rb +0 -18
- data/spec/example_spec.rb +0 -37
- data/spec/file_spec.rb +0 -20
- data/spec/outline_spec.rb +0 -32
- data/spec/scenario_spec.rb +0 -33
- data/spec/step_spec.rb +0 -24
@@ -1,78 +0,0 @@
|
|
1
|
-
module CucumberAnalytics
|
2
|
-
class ParsedDirectory
|
3
|
-
|
4
|
-
|
5
|
-
attr_reader :feature_files
|
6
|
-
attr_reader :feature_directories
|
7
|
-
attr_accessor :parent_element
|
8
|
-
|
9
|
-
|
10
|
-
# Creates a new ParsedDirectory object and, if *directory_parsed* is
|
11
|
-
# provided, populates the object.
|
12
|
-
def initialize(directory_parsed = nil)
|
13
|
-
CucumberAnalytics::Logging.logger.info('ParsedDirectory#initialize')
|
14
|
-
|
15
|
-
@directory = directory_parsed
|
16
|
-
|
17
|
-
@feature_files = []
|
18
|
-
@feature_directories = []
|
19
|
-
|
20
|
-
scan_directory if directory_parsed
|
21
|
-
end
|
22
|
-
|
23
|
-
# Returns the name of the directory.
|
24
|
-
def name
|
25
|
-
File.basename(@directory.gsub('\\', '/'))
|
26
|
-
end
|
27
|
-
|
28
|
-
# Returns the path of the directory.
|
29
|
-
def path
|
30
|
-
@directory
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns the number of sub-directories contained in the directory.
|
34
|
-
def directory_count
|
35
|
-
@feature_directories.count
|
36
|
-
end
|
37
|
-
|
38
|
-
# Returns the number of features files contained in the directory.
|
39
|
-
def feature_file_count
|
40
|
-
@feature_files.count
|
41
|
-
end
|
42
|
-
|
43
|
-
# Returns the immediate child elements of the directory (i.e. its .feature
|
44
|
-
# files and .feature file containing sub-directories).
|
45
|
-
def contains
|
46
|
-
@feature_files + @feature_directories
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
|
53
|
-
def scan_directory
|
54
|
-
entries = Dir.entries(@directory)
|
55
|
-
entries.delete '.'
|
56
|
-
entries.delete '..'
|
57
|
-
|
58
|
-
entries.each do |entry|
|
59
|
-
entry = @directory + '/' + entry
|
60
|
-
|
61
|
-
if File.directory?(entry)
|
62
|
-
found_directory = ParsedDirectory.new(entry)
|
63
|
-
found_directory.parent_element = self
|
64
|
-
|
65
|
-
@feature_directories << found_directory
|
66
|
-
end
|
67
|
-
|
68
|
-
if entry =~ /\.feature$/
|
69
|
-
found_feature_file = ParsedFile.new(entry)
|
70
|
-
found_feature_file.parent_element = self
|
71
|
-
|
72
|
-
@feature_files << found_feature_file
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
module CucumberAnalytics
|
2
|
-
class ParsedFeature < FeatureElement
|
3
|
-
|
4
|
-
|
5
|
-
attr_accessor :tags
|
6
|
-
attr_accessor :background
|
7
|
-
attr_accessor :tests
|
8
|
-
|
9
|
-
|
10
|
-
# Creates a new ParsedFeature object and, if *source_lines* is provided,
|
11
|
-
# populates the object.
|
12
|
-
def initialize(source_lines = nil)
|
13
|
-
CucumberAnalytics::Logging.logger.info('ParsedFeature#initialize')
|
14
|
-
|
15
|
-
super
|
16
|
-
|
17
|
-
@tags = []
|
18
|
-
@tests = []
|
19
|
-
|
20
|
-
parse_feature(source_lines) if source_lines
|
21
|
-
end
|
22
|
-
|
23
|
-
# Returns true if the feature contains a background, false otherwise.
|
24
|
-
def has_background?
|
25
|
-
!@background.nil?
|
26
|
-
end
|
27
|
-
|
28
|
-
# Returns the scenarios contained in the feature.
|
29
|
-
def scenarios
|
30
|
-
@tests.select { |test| test.is_a? ParsedScenario }
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns the outlines contained in the feature.
|
34
|
-
def outlines
|
35
|
-
@tests.select { |test| test.is_a? ParsedScenarioOutline }
|
36
|
-
end
|
37
|
-
|
38
|
-
# Returns the number scenarios contained in the feature.
|
39
|
-
def scenario_count
|
40
|
-
scenarios.count
|
41
|
-
end
|
42
|
-
|
43
|
-
# Returns the number outlines contained in the feature.
|
44
|
-
def outline_count
|
45
|
-
outlines.count
|
46
|
-
end
|
47
|
-
|
48
|
-
# Returns the number of tests contained in the feature.
|
49
|
-
def test_count
|
50
|
-
@tests.count
|
51
|
-
end
|
52
|
-
|
53
|
-
# Returns the number of test cases contained in the feature.
|
54
|
-
def test_case_count
|
55
|
-
scenario_count + outlines.reduce(0) { |outline_sum, outline|
|
56
|
-
outline_sum += outline.examples.reduce(0) { |example_sum, example|
|
57
|
-
example_sum += example.rows.count
|
58
|
-
}
|
59
|
-
}
|
60
|
-
end
|
61
|
-
|
62
|
-
# Returns the immediate child elements of the feature (i.e. its background
|
63
|
-
# and tests).
|
64
|
-
def contains
|
65
|
-
[@background] + @tests
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
|
72
|
-
def parse_feature(source_lines)
|
73
|
-
CucumberAnalytics::Logging.logger.info('ParsedFeature#parse_feature')
|
74
|
-
|
75
|
-
parse_feature_element_tags(source_lines)
|
76
|
-
parse_feature_element(source_lines)
|
77
|
-
end
|
78
|
-
|
79
|
-
def parse_feature_element_description(source_lines)
|
80
|
-
CucumberAnalytics::Logging.logger.info('ParsedFeature#parse_feature_element_description')
|
81
|
-
CucumberAnalytics::Logging.logger.debug('source lines')
|
82
|
-
source_lines.each do |line|
|
83
|
-
CucumberAnalytics::Logging.logger.debug(line.chomp)
|
84
|
-
end
|
85
|
-
|
86
|
-
source_lines.delete_if { |line| World.ignored_line?(line) }
|
87
|
-
|
88
|
-
until source_lines.first =~ /#{World::TEST_ELEMENT_START_PATTERN}/ or
|
89
|
-
source_lines.empty?
|
90
|
-
|
91
|
-
@description << source_lines.first.strip
|
92
|
-
source_lines.shift
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
@@ -1,199 +0,0 @@
|
|
1
|
-
module CucumberAnalytics
|
2
|
-
class ParsedFile
|
3
|
-
|
4
|
-
|
5
|
-
attr_reader :feature
|
6
|
-
attr_accessor :parent_element
|
7
|
-
|
8
|
-
|
9
|
-
# Creates a new ParsedFile object and, if *file_parsed* is provided,
|
10
|
-
# populates the object.
|
11
|
-
def initialize(file_parsed = nil)
|
12
|
-
CucumberAnalytics::Logging.logger.info('ParsedFile#initialize')
|
13
|
-
|
14
|
-
parse_file(file_parsed) if file_parsed
|
15
|
-
end
|
16
|
-
|
17
|
-
# Returns the name of the file.
|
18
|
-
def name
|
19
|
-
File.basename(@file.gsub('\\', '/'))
|
20
|
-
end
|
21
|
-
|
22
|
-
# Returns the path of the file.
|
23
|
-
def path
|
24
|
-
@file
|
25
|
-
end
|
26
|
-
|
27
|
-
# Returns the immediate child elements of the feature file(i.e. its
|
28
|
-
# feature).
|
29
|
-
def contains
|
30
|
-
@feature ? [@feature] : []
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns the number of features contained in the file.
|
34
|
-
def feature_count
|
35
|
-
@feature.nil? ? 0 : 1
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
|
42
|
-
def parse_file(file_parsed)
|
43
|
-
CucumberAnalytics::Logging.logger.info('ParsedFile#parse_file')
|
44
|
-
CucumberAnalytics::Logging.logger.debug("Parsing file: #{file_parsed}")
|
45
|
-
|
46
|
-
@file = file_parsed
|
47
|
-
|
48
|
-
file_lines = []
|
49
|
-
feature_lines = []
|
50
|
-
background_lines = []
|
51
|
-
|
52
|
-
File.open(@file, 'r') { |file| file_lines = file.readlines }
|
53
|
-
|
54
|
-
# collect feature tag lines
|
55
|
-
until file_lines.first =~ /^\s*Feature:/ or
|
56
|
-
file_lines.empty?
|
57
|
-
|
58
|
-
feature_lines << file_lines.first
|
59
|
-
file_lines.shift
|
60
|
-
end
|
61
|
-
|
62
|
-
# collect everything else until the end of the feature section
|
63
|
-
until file_lines.first =~ /#{World::TEST_ELEMENT_START_PATTERN}/ or
|
64
|
-
file_lines.empty?
|
65
|
-
|
66
|
-
feature_lines << file_lines.first
|
67
|
-
file_lines.shift
|
68
|
-
end
|
69
|
-
|
70
|
-
# create a new feature bases on the collected lines
|
71
|
-
if feature_lines.empty?
|
72
|
-
@feature = nil
|
73
|
-
else
|
74
|
-
found_feature = ParsedFeature.new(feature_lines)
|
75
|
-
found_feature.parent_element = self
|
76
|
-
|
77
|
-
@feature = found_feature
|
78
|
-
end
|
79
|
-
|
80
|
-
|
81
|
-
if file_lines.first =~ /^\s*Background:/
|
82
|
-
|
83
|
-
# collect the background description lines
|
84
|
-
until (file_lines.first =~ /^\s*(?:(?:Given )|(?:When )|(?:Then )|(?:And )|(?:\* )|@|Scenario:|(?:Scenario Outline:))/) or
|
85
|
-
file_lines.empty?
|
86
|
-
|
87
|
-
background_lines << file_lines.first
|
88
|
-
file_lines.shift
|
89
|
-
end
|
90
|
-
|
91
|
-
# collect everything else up to the first test
|
92
|
-
until file_lines.first =~ /^\s*(?:@|Scenario:|(?:Scenario Outline:))/ or
|
93
|
-
file_lines.empty?
|
94
|
-
|
95
|
-
if file_lines.first =~ /^\s*"""/
|
96
|
-
background_lines.concat(extract_doc_string!(file_lines))
|
97
|
-
else
|
98
|
-
background_lines << file_lines.first
|
99
|
-
file_lines.shift
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# create a new background based on the collected lines
|
104
|
-
found_background = ParsedBackground.new(background_lines)
|
105
|
-
found_background.parent_element = @feature
|
106
|
-
|
107
|
-
@feature.background = found_background
|
108
|
-
end
|
109
|
-
|
110
|
-
parse_tests(file_lines)
|
111
|
-
end
|
112
|
-
|
113
|
-
def parse_tests(lines)
|
114
|
-
CucumberAnalytics::Logging.logger.info('ParsedFile#parse_tests')
|
115
|
-
CucumberAnalytics::Logging.logger.debug('lines')
|
116
|
-
lines.each do |line|
|
117
|
-
CucumberAnalytics::Logging.logger.debug(line.chomp)
|
118
|
-
end
|
119
|
-
|
120
|
-
until lines.empty?
|
121
|
-
# we'll need this in order to figure out whether we are dealing with a
|
122
|
-
# scenario or an outline
|
123
|
-
current_test_line = lines.index { |line| line =~ /^\s*(?:Scenario:|(?:Scenario Outline:))/ }
|
124
|
-
|
125
|
-
test_lines = []
|
126
|
-
|
127
|
-
# collect the tag lines
|
128
|
-
until lines.first =~ /^\s*(?:Scenario:|(?:Scenario Outline:))/
|
129
|
-
test_lines << lines.first
|
130
|
-
lines.shift
|
131
|
-
end
|
132
|
-
|
133
|
-
test_lines << lines.first
|
134
|
-
lines.shift
|
135
|
-
|
136
|
-
# collect the description lines
|
137
|
-
until (lines.first =~ /^\s*(?:(?:Given )|(?:When )|(?:Then )|(?:And )|(?:\* )|Scenario:|(?:Scenario Outline:))/) or
|
138
|
-
lines.empty?
|
139
|
-
|
140
|
-
test_lines << lines.first
|
141
|
-
lines.shift
|
142
|
-
end
|
143
|
-
|
144
|
-
# collect everything else up to the next test
|
145
|
-
until (lines.first =~ /^\s*(?:Scenario:|(?:Scenario Outline:))/) or
|
146
|
-
lines.empty?
|
147
|
-
|
148
|
-
if (lines.first =~ /^\s*"""/)
|
149
|
-
test_lines.concat(extract_doc_string!(lines))
|
150
|
-
else
|
151
|
-
test_lines << lines.first
|
152
|
-
lines.shift
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
# backtrack in order to not end up stealing the next test's tag lines
|
157
|
-
unless lines.empty?
|
158
|
-
while (test_lines.last =~ /^\s*@/) or World.ignored_line?(test_lines.last)
|
159
|
-
lines = [test_lines.pop].concat(lines)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
# use the collected lines to create a scenario or an outline accordingly
|
164
|
-
if test_lines[current_test_line] =~ /^\s*Scenario Outline:/
|
165
|
-
next_test = ParsedScenarioOutline.new(test_lines)
|
166
|
-
else
|
167
|
-
next_test = ParsedScenario.new(test_lines)
|
168
|
-
end
|
169
|
-
|
170
|
-
next_test.parent_element = @feature
|
171
|
-
@feature.tests << next_test
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
def extract_doc_string!(lines)
|
176
|
-
CucumberAnalytics::Logging.logger.info('ParsedFile#extract_doc_string!')
|
177
|
-
CucumberAnalytics::Logging.logger.debug('lines')
|
178
|
-
lines.each do |line|
|
179
|
-
CucumberAnalytics::Logging.logger.debug(line.chomp)
|
180
|
-
end
|
181
|
-
|
182
|
-
doc_block = []
|
183
|
-
|
184
|
-
doc_block << lines.first
|
185
|
-
lines.shift
|
186
|
-
|
187
|
-
until lines.first =~ /^\s*"""/
|
188
|
-
doc_block << lines.first
|
189
|
-
lines.shift
|
190
|
-
end
|
191
|
-
|
192
|
-
doc_block << lines.first
|
193
|
-
lines.shift
|
194
|
-
|
195
|
-
doc_block
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
199
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
module CucumberAnalytics
|
2
|
-
class ParsedScenario < TestElement
|
3
|
-
|
4
|
-
|
5
|
-
attr_accessor :tags
|
6
|
-
|
7
|
-
|
8
|
-
# Creates a new ParsedScenario object and, if *source_lines* is provided,
|
9
|
-
# populates the object.
|
10
|
-
def initialize(source_lines = nil)
|
11
|
-
CucumberAnalytics::Logging.logger.info('ParsedScenario#initialize')
|
12
|
-
CucumberAnalytics::Logging.logger.debug('source lines')
|
13
|
-
source_lines.each { |line| CucumberAnalytics::Logging.logger.debug(line.chomp) } if source_lines
|
14
|
-
|
15
|
-
super
|
16
|
-
|
17
|
-
@tags = []
|
18
|
-
|
19
|
-
parse_scenario(source_lines) if source_lines
|
20
|
-
end
|
21
|
-
|
22
|
-
# Returns tags which are applicable to the scenario which have been
|
23
|
-
# inherited from the feature level.
|
24
|
-
def applied_tags
|
25
|
-
additional_tags = @parent_element.tags
|
26
|
-
additional_tags.concat(@parent_element.applied_tags) if @parent_element.respond_to?(:applied_tags)
|
27
|
-
|
28
|
-
additional_tags
|
29
|
-
end
|
30
|
-
|
31
|
-
# Returns all tags which are applicable to the scenario.
|
32
|
-
def all_tags
|
33
|
-
applied_tags + @tags
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
|
40
|
-
def parse_scenario(source_lines)
|
41
|
-
CucumberAnalytics::Logging.logger.info('ParsedScenario#parse_scenario')
|
42
|
-
|
43
|
-
parse_feature_element_tags(source_lines)
|
44
|
-
parse_feature_element(source_lines)
|
45
|
-
parse_test_element_steps(source_lines)
|
46
|
-
end
|
47
|
-
|
48
|
-
def parse_feature_element_description(source_lines)
|
49
|
-
CucumberAnalytics::Logging.logger.info('ParsedScenario#parse_feature_element_description')
|
50
|
-
CucumberAnalytics::Logging.logger.debug('source lines')
|
51
|
-
source_lines.each do |line|
|
52
|
-
CucumberAnalytics::Logging.logger.debug(line.chomp)
|
53
|
-
end
|
54
|
-
|
55
|
-
until source_lines.first =~ /^\s*(?:(?:Given )|(?:When )|(?:Then )|(?:And )|(?:\* ))/ or
|
56
|
-
source_lines.empty?
|
57
|
-
|
58
|
-
unless World.ignored_line?(source_lines.first)
|
59
|
-
@description << source_lines.first.strip
|
60
|
-
end
|
61
|
-
|
62
|
-
source_lines.shift
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
module CucumberAnalytics
|
2
|
-
class ParsedScenarioOutline < TestElement
|
3
|
-
|
4
|
-
|
5
|
-
attr_accessor :tags
|
6
|
-
attr_accessor :examples
|
7
|
-
|
8
|
-
|
9
|
-
# Creates a new ParsedScenarioOutline object and, if *source_lines* is
|
10
|
-
# provided, populates the object.
|
11
|
-
def initialize(source_lines = nil)
|
12
|
-
CucumberAnalytics::Logging.logger.info('ParsedScenarioOutline#initialize')
|
13
|
-
CucumberAnalytics::Logging.logger.debug('source lines')
|
14
|
-
source_lines.each { |line| CucumberAnalytics::Logging.logger.debug(line.chomp) } if source_lines
|
15
|
-
|
16
|
-
super
|
17
|
-
|
18
|
-
@tags = []
|
19
|
-
@examples = []
|
20
|
-
|
21
|
-
parse_outline(source_lines) if source_lines
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns the immediate child elements of the outline (i.e. its example
|
25
|
-
# blocks).
|
26
|
-
def contains
|
27
|
-
@examples
|
28
|
-
end
|
29
|
-
|
30
|
-
# Returns tags which have been inherited from the feature level.
|
31
|
-
def applied_tags
|
32
|
-
additional_tags = @parent_element.tags
|
33
|
-
additional_tags.concat(@parent_element.applied_tags) if @parent_element.respond_to?(:applied_tags)
|
34
|
-
|
35
|
-
additional_tags
|
36
|
-
end
|
37
|
-
|
38
|
-
# Returns all tags which are applicable to the scenario.
|
39
|
-
def all_tags
|
40
|
-
applied_tags + @tags
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
|
47
|
-
def parse_outline(source_lines)
|
48
|
-
CucumberAnalytics::Logging.logger.info('ParsedScenarioOutline#parse_outline')
|
49
|
-
|
50
|
-
parse_feature_element_tags(source_lines)
|
51
|
-
parse_feature_element(source_lines)
|
52
|
-
parse_test_element_steps(source_lines)
|
53
|
-
parse_outline_examples(source_lines)
|
54
|
-
end
|
55
|
-
|
56
|
-
def parse_feature_element_description(source_lines)
|
57
|
-
CucumberAnalytics::Logging.logger.info('ParsedScenarioOutline#parse_feature_element_description')
|
58
|
-
CucumberAnalytics::Logging.logger.debug('source lines')
|
59
|
-
source_lines.each do |line|
|
60
|
-
CucumberAnalytics::Logging.logger.debug(line.chomp)
|
61
|
-
end
|
62
|
-
|
63
|
-
until source_lines.first =~ /^\s*(?:(?:Given )|(?:When )|(?:Then )|(?:And )|(?:\* )| (?:Examples: ))/ or
|
64
|
-
source_lines.empty?
|
65
|
-
|
66
|
-
unless World.ignored_line?(source_lines.first)
|
67
|
-
@description << source_lines.first.strip
|
68
|
-
end
|
69
|
-
|
70
|
-
source_lines.shift
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def parse_outline_examples(source_lines)
|
75
|
-
CucumberAnalytics::Logging.logger.info('ParsedScenarioOutline#parse_outline_examples')
|
76
|
-
CucumberAnalytics::Logging.logger.debug('source lines')
|
77
|
-
source_lines.each do |line|
|
78
|
-
CucumberAnalytics::Logging.logger.debug(line.chomp)
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
until source_lines.empty?
|
83
|
-
example_lines = []
|
84
|
-
|
85
|
-
# collect the tag lines
|
86
|
-
until source_lines.first =~ /^\s*Examples:/
|
87
|
-
example_lines << source_lines.first
|
88
|
-
source_lines.shift
|
89
|
-
end
|
90
|
-
|
91
|
-
example_lines << source_lines.first
|
92
|
-
source_lines.shift
|
93
|
-
|
94
|
-
# collect the description lines
|
95
|
-
until (source_lines.first =~ /^\s*\|/) or source_lines.empty?
|
96
|
-
example_lines << source_lines.first
|
97
|
-
source_lines.shift
|
98
|
-
end
|
99
|
-
|
100
|
-
# collect everything else up to the next example
|
101
|
-
until (source_lines.first =~ /^\s*Examples:/) or source_lines.empty?
|
102
|
-
example_lines << source_lines.first
|
103
|
-
source_lines.shift
|
104
|
-
end
|
105
|
-
|
106
|
-
# backtrack in order to not end up stealing the next test's tag lines
|
107
|
-
unless source_lines.empty?
|
108
|
-
while (example_lines.last =~ /^\s*@/) or World.ignored_line?(example_lines.last)
|
109
|
-
source_lines = [example_lines.pop].concat(source_lines)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
# use the collected lines to create an example
|
114
|
-
example = OutlineExample.new(example_lines)
|
115
|
-
example.parent_element = self
|
116
|
-
|
117
|
-
@examples << example
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
122
|
-
end
|
data/spec/background_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
SimpleCov.command_name('ParsedBackground') unless RUBY_VERSION.to_s < '1.9.0'
|
4
|
-
|
5
|
-
describe "ParsedBackground" do
|
6
|
-
|
7
|
-
it 'knows its parent element' do
|
8
|
-
file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
9
|
-
|
10
|
-
File.open(file_path, "w") { |file|
|
11
|
-
file.puts('Feature: Test feature')
|
12
|
-
file.puts(' Background: Test background')
|
13
|
-
}
|
14
|
-
|
15
|
-
file = CucumberAnalytics::ParsedFile.new(file_path)
|
16
|
-
|
17
|
-
feature = file.feature
|
18
|
-
background = feature.background
|
19
|
-
|
20
|
-
background.parent_element.should equal feature
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/spec/directory_spec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
SimpleCov.command_name('ParsedDirectory') unless RUBY_VERSION.to_s < '1.9.0'
|
4
|
-
|
5
|
-
describe "ParsedDirectory" do
|
6
|
-
|
7
|
-
it 'knows its parent element' do
|
8
|
-
directory = @default_file_directory
|
9
|
-
nested_directory = "#{directory}/nested_directory"
|
10
|
-
FileUtils.mkdir(nested_directory)
|
11
|
-
|
12
|
-
directory = CucumberAnalytics::ParsedDirectory.new(@default_file_directory)
|
13
|
-
nested_directory = directory.feature_directories.first
|
14
|
-
|
15
|
-
nested_directory.parent_element.should equal directory
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/spec/example_spec.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
SimpleCov.command_name('OutlineExample') unless RUBY_VERSION.to_s < '1.9.0'
|
4
|
-
|
5
|
-
describe "OutlineExample" do
|
6
|
-
|
7
|
-
it "knows all of its tags" do
|
8
|
-
feature = CucumberAnalytics::ParsedFeature.new
|
9
|
-
feature.tags = ['@feature_tag']
|
10
|
-
outline = CucumberAnalytics::ParsedScenarioOutline.new
|
11
|
-
outline.tags = ['@outline_tag']
|
12
|
-
example = CucumberAnalytics::OutlineExample.new
|
13
|
-
example.tags = ['@example_tag']
|
14
|
-
|
15
|
-
outline.parent_element = feature
|
16
|
-
example.parent_element = outline
|
17
|
-
example.all_tags.sort.should == ['@feature_tag', '@outline_tag', '@example_tag'].sort
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'knows its parent element' do
|
21
|
-
file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
22
|
-
|
23
|
-
File.open(file_path, "w") { |file|
|
24
|
-
file.puts('Feature: Test feature')
|
25
|
-
file.puts(' Scenario Outline: Test outline')
|
26
|
-
file.puts(' Examples: test examples')
|
27
|
-
}
|
28
|
-
|
29
|
-
file = CucumberAnalytics::ParsedFile.new(file_path)
|
30
|
-
|
31
|
-
outline = file.feature.tests.first
|
32
|
-
example = outline.examples.first
|
33
|
-
|
34
|
-
example.parent_element.should equal outline
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/spec/file_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
SimpleCov.command_name('ParsedFile') unless RUBY_VERSION.to_s < '1.9.0'
|
4
|
-
|
5
|
-
describe "ParsedFile" do
|
6
|
-
|
7
|
-
it 'knows its parent element' do
|
8
|
-
file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
9
|
-
|
10
|
-
File.open(file_path, "w") { |file|
|
11
|
-
file.puts('Feature: Test feature')
|
12
|
-
}
|
13
|
-
|
14
|
-
directory = CucumberAnalytics::ParsedDirectory.new(@default_file_directory)
|
15
|
-
file = directory.feature_files.first
|
16
|
-
|
17
|
-
file.parent_element.should equal directory
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
data/spec/outline_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
SimpleCov.command_name('ParsedOutline') unless RUBY_VERSION.to_s < '1.9.0'
|
4
|
-
|
5
|
-
describe "ParsedOutline" do
|
6
|
-
|
7
|
-
it "knows all of its tags" do
|
8
|
-
feature = CucumberAnalytics::ParsedFeature.new
|
9
|
-
feature.tags = ['@feature_tag']
|
10
|
-
outline = CucumberAnalytics::ParsedScenarioOutline.new
|
11
|
-
outline.tags = ['@outline_tag']
|
12
|
-
|
13
|
-
outline.parent_element = feature
|
14
|
-
outline.all_tags.sort.should == ['@feature_tag', '@outline_tag'].sort
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'knows its parent element' do
|
18
|
-
file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
19
|
-
|
20
|
-
File.open(file_path, "w") { |file|
|
21
|
-
file.puts('Feature: Test feature')
|
22
|
-
file.puts(' Scenario Outline: Test outline')
|
23
|
-
}
|
24
|
-
|
25
|
-
file = CucumberAnalytics::ParsedFile.new(file_path)
|
26
|
-
|
27
|
-
feature = file.feature
|
28
|
-
outline = feature.tests.first
|
29
|
-
|
30
|
-
outline.parent_element.should equal feature
|
31
|
-
end
|
32
|
-
end
|