cucumber_analytics 0.0.7 → 0.0.8
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.
- data/History.rdoc +10 -1
- data/features/analysis/directory_collection.feature +25 -0
- data/features/modeling/background_modeling.feature +1 -1
- data/features/modeling/directory_modeling.feature +24 -6
- data/features/modeling/example_modeling.feature +5 -5
- data/features/modeling/feature_modeling.feature +2 -2
- data/features/modeling/outline_modeling.feature +2 -2
- data/features/modeling/scenario_modeling.feature +1 -1
- data/features/step_definitions/directory_steps.rb +18 -0
- data/features/step_definitions/feature_steps.rb +3 -2
- data/features/step_definitions/test_steps.rb +4 -1
- data/features/step_definitions/world_steps.rb +17 -0
- data/lib/cucumber_analytics/outline_example.rb +1 -1
- data/lib/cucumber_analytics/parsed_directory.rb +5 -0
- data/lib/cucumber_analytics/parsed_feature.rb +1 -1
- data/lib/cucumber_analytics/parsed_file.rb +2 -2
- data/lib/cucumber_analytics/parsed_scenario.rb +1 -1
- data/lib/cucumber_analytics/parsed_scenario_outline.rb +1 -1
- data/lib/cucumber_analytics/version.rb +1 -1
- data/lib/cucumber_analytics/world.rb +19 -0
- metadata +4 -2
data/History.rdoc
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
+
=== Version 0.0.8 / 2013-02-24
|
2
|
+
|
3
|
+
* Bug fix: Replaced some destructive method calls with non-destructive
|
4
|
+
equivalents.
|
5
|
+
* Bug fix: Fixed some parsing bugs based around whitespace.
|
6
|
+
* Subdirectories within a directory are now modeled.
|
7
|
+
* Directory collection added
|
8
|
+
|
9
|
+
|
1
10
|
=== Version 0.0.7 / 2013-02-01
|
2
11
|
|
3
12
|
* Bug fix: Feature collection no longer returns nil values for feature files
|
4
13
|
that do not contain features.
|
5
14
|
* Elements now know the element that contains them.
|
6
|
-
* Adjusted the default logging level so
|
15
|
+
* Adjusted the default logging level so that logging does not occur by default.
|
7
16
|
|
8
17
|
|
9
18
|
=== Version 0.0.6 / 2013-01-07
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: Directories can be collected from arbitrary parts of the codebase.
|
2
|
+
|
3
|
+
|
4
|
+
Acceptance criteria
|
5
|
+
|
6
|
+
Directories containing feature files can be collected from:
|
7
|
+
1. directories
|
8
|
+
|
9
|
+
|
10
|
+
Background: Setup test codebase
|
11
|
+
Given a directory "feature_directory"
|
12
|
+
And a directory "feature_directory/nested_directory_1"
|
13
|
+
And a directory "feature_directory/nested_directory_1/nested_directory_2"
|
14
|
+
When the directory "feature_directory" is read
|
15
|
+
And the directory "feature_directory/nested_directory_1" is read
|
16
|
+
And the directory "feature_directory/nested_directory_1/nested_directory_2" is read
|
17
|
+
|
18
|
+
|
19
|
+
Scenario: Directories can be collected from directories
|
20
|
+
Then the directories collected from directory "1" are as follows:
|
21
|
+
| nested_directory_1 |
|
22
|
+
| nested_directory_2 |
|
23
|
+
And the directories collected from directory "2" are as follows:
|
24
|
+
| nested_directory_2 |
|
25
|
+
And there are no directories collected from directory "3"
|
@@ -14,7 +14,7 @@ Feature: Background elements can be modeled.
|
|
14
14
|
Feature: The test feature name.
|
15
15
|
Some more feature description.
|
16
16
|
|
17
|
-
Background:
|
17
|
+
Background:Some general test setup stuff.
|
18
18
|
My big hunk of perfectly valid description:
|
19
19
|
|
|
20
20
|
|
@@ -7,6 +7,7 @@ Feature: Directories can be modeled.
|
|
7
7
|
1. the directory's name
|
8
8
|
2. the directory's full path
|
9
9
|
3. all feature files contained
|
10
|
+
4. all directories contained
|
10
11
|
|
11
12
|
|
12
13
|
Background: Setup test directories
|
@@ -68,23 +69,40 @@ Feature: Directories can be modeled.
|
|
68
69
|
When the directory "feature_directory" is read
|
69
70
|
And the directory "feature_directory/nested_directory" is read
|
70
71
|
|
72
|
+
Scenario: The directory's name is modeled.
|
73
|
+
Then directory "1" is found to have the following properties:
|
74
|
+
| name | feature_directory |
|
75
|
+
And directory "2" is found to have the following properties:
|
76
|
+
| name | nested_directory |
|
77
|
+
|
78
|
+
Scenario: The directory's full path is modeled.
|
79
|
+
Then directory "1" is found to have the following properties:
|
80
|
+
| path | path_to/feature_directory |
|
81
|
+
And directory "2" is found to have the following properties:
|
82
|
+
| path | path_to/feature_directory/nested_directory |
|
83
|
+
|
71
84
|
Scenario: The directory's feature files are modeled.
|
72
85
|
Then directory "1" is found to have the following properties:
|
73
|
-
|
|
74
|
-
| path | path_to/feature_directory |
|
75
|
-
| feature_file_count | 3 |
|
86
|
+
| feature_file_count | 3 |
|
76
87
|
And directory "1" feature files are as follows:
|
77
88
|
| test_file_1.feature |
|
78
89
|
| test_file_2.feature |
|
79
90
|
| test_file_3.feature |
|
80
91
|
Then directory "2" is found to have the following properties:
|
81
|
-
|
|
82
|
-
| path | path_to/feature_directory/nested_directory |
|
83
|
-
| feature_file_count | 2 |
|
92
|
+
| feature_file_count | 2 |
|
84
93
|
And directory "2" feature files are as follows:
|
85
94
|
| test_file_4.feature |
|
86
95
|
| test_file_5.feature |
|
87
96
|
|
97
|
+
Scenario: The directory's directories are modeled.
|
98
|
+
Then directory "1" is found to have the following properties:
|
99
|
+
| directory_count | 1 |
|
100
|
+
And directory "1" directories are as follows:
|
101
|
+
| nested_directory |
|
102
|
+
Then directory "2" is found to have the following properties:
|
103
|
+
| directory_count | 0 |
|
104
|
+
And directory "2" has no directories
|
105
|
+
|
88
106
|
Scenario Outline: Directory models pass all other specifications
|
89
107
|
Exact specifications detailing the API for directory models.
|
90
108
|
Given that there are "<additional specifications>" detailing models
|
@@ -25,15 +25,15 @@ Feature: Example elements can be modeled.
|
|
25
25
|
| <param2> |
|
26
26
|
Then I don't really need another step
|
27
27
|
|
28
|
-
Examples:
|
28
|
+
Examples:text describing the significance of the examples
|
29
29
|
Anything besides the | that starts a row should be valid
|
30
30
|
description at this point in the test. YMMV
|
31
|
-
|
|
31
|
+
|param1| param2 | extra param |
|
32
32
|
#A more random comment
|
33
|
-
|
|
34
|
-
|
|
33
|
+
|x | y | ? |
|
34
|
+
|1 | 2 | 3 |
|
35
35
|
@example_tag @another_one
|
36
|
-
Examples:
|
36
|
+
Examples:some examples with different significance and a tag
|
37
37
|
|
38
38
|
Words, words, words, words,
|
39
39
|
|
@@ -21,7 +21,7 @@ Feature: Features can be modeled.
|
|
21
21
|
#Or any line that is a comment, really.
|
22
22
|
@a_feature_level_tag @and_another@and_another
|
23
23
|
|
24
|
-
|
24
|
+
Feature:The test feature name.
|
25
25
|
Some more feature description.
|
26
26
|
|
27
27
|
And some more.
|
@@ -44,7 +44,7 @@ Feature: Features can be modeled.
|
|
44
44
|
# freeform text for some reason.
|
45
45
|
|
46
46
|
|
47
|
-
Background:
|
47
|
+
Background:Some general test setup stuff.
|
48
48
|
A little more information.
|
49
49
|
* some setup step
|
50
50
|
|
@@ -20,7 +20,7 @@ Feature: Scenario Outline elements can be modeled.
|
|
20
20
|
Some more feature description.
|
21
21
|
|
22
22
|
@outline_tag
|
23
|
-
Scenario Outline:
|
23
|
+
Scenario Outline:The scenario outline's name.
|
24
24
|
My big hunk of perfectly valid description:
|
25
25
|
|
|
26
26
|
|
@@ -62,7 +62,7 @@ Feature: Scenario Outline elements can be modeled.
|
|
62
62
|
\"\"\"
|
63
63
|
Then *lots* *of* *parameters*
|
64
64
|
|
65
|
-
Examples:
|
65
|
+
Examples:text describing the significance of the examples
|
66
66
|
Anything besides the | that starts a row should be valid
|
67
67
|
description at this point in the test. YMMV
|
68
68
|
| param1 | param2 |
|
@@ -18,3 +18,21 @@ When /^(?:the )?directory(?: "([^"]*)")? feature files are as follows:$/ do |dir
|
|
18
18
|
|
19
19
|
assert actual_files.flatten.sort == files.raw.flatten.sort
|
20
20
|
end
|
21
|
+
|
22
|
+
When /^(?:the )?directory(?: "([^"]*)")? directories are as follows:$/ do |directory, directories|
|
23
|
+
directory ||= 1
|
24
|
+
|
25
|
+
expected = directories.raw.flatten.sort
|
26
|
+
actual = @parsed_directories[directory - 1].feature_directories.collect { |sub_directory| sub_directory.name }
|
27
|
+
|
28
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
29
|
+
end
|
30
|
+
|
31
|
+
When /^(?:the )?directory(?: "([^"]*)")? has no directories$/ do |directory|
|
32
|
+
directory ||= 1
|
33
|
+
|
34
|
+
expected = []
|
35
|
+
actual = @parsed_directories[directory - 1].feature_directories
|
36
|
+
|
37
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
38
|
+
end
|
@@ -11,9 +11,10 @@ Then /^(?:the )?feature(?: "([^"]*)")? is found to have the following properties
|
|
11
11
|
end
|
12
12
|
|
13
13
|
Then /^the descriptive lines of feature "([^"]*)" are as follows:$/ do |file, lines|
|
14
|
-
|
14
|
+
expected = lines.raw.flatten
|
15
|
+
actual = @parsed_files[file - 1].feature.description
|
15
16
|
|
16
|
-
assert
|
17
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
17
18
|
end
|
18
19
|
|
19
20
|
Then /^feature "([^"]*)" is found to have the following tags:$/ do |file, tags|
|
@@ -49,7 +49,10 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the
|
|
49
49
|
file ||= 1
|
50
50
|
test ||= 1
|
51
51
|
|
52
|
-
|
52
|
+
expected = tags.raw.flatten
|
53
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].tags
|
54
|
+
|
55
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
53
56
|
end
|
54
57
|
|
55
58
|
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the following applied tags:$/ do |file, test, tags|
|
@@ -157,3 +157,20 @@ Then /^the files collected from directory "([^"]*)" are as follows:$/ do |direct
|
|
157
157
|
|
158
158
|
assert actual_files.flatten.sort == files.raw.flatten.sort
|
159
159
|
end
|
160
|
+
|
161
|
+
Then /^the directories collected from directory "([^"]*)" are as follows:$/ do |directory, directories|
|
162
|
+
directory ||= 1
|
163
|
+
|
164
|
+
expected = directories.raw.flatten.sort
|
165
|
+
actual = CucumberAnalytics::World.directories_in(@parsed_directories[directory - 1]).collect { |sub_directory| sub_directory.name }
|
166
|
+
|
167
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
168
|
+
end
|
169
|
+
|
170
|
+
Then /^there are no directories collected from directory "([^"]*)"$/ do |directory|
|
171
|
+
directory ||= 1
|
172
|
+
|
173
|
+
actual_directories = CucumberAnalytics::World.directories_in(@parsed_directories[directory - 1])
|
174
|
+
|
175
|
+
assert actual_directories.flatten == []
|
176
|
+
end
|
@@ -30,6 +30,11 @@ module CucumberAnalytics
|
|
30
30
|
@directory
|
31
31
|
end
|
32
32
|
|
33
|
+
# Returns the number of sub-directories contained in the directory.
|
34
|
+
def directory_count
|
35
|
+
@feature_directories.count
|
36
|
+
end
|
37
|
+
|
33
38
|
# Returns the number of features files contained in the directory.
|
34
39
|
def feature_file_count
|
35
40
|
@feature_files.count
|
@@ -85,7 +85,7 @@ module CucumberAnalytics
|
|
85
85
|
|
86
86
|
source_lines.delete_if { |line| World.ignored_line?(line) }
|
87
87
|
|
88
|
-
until source_lines.first =~
|
88
|
+
until source_lines.first =~ /#{World::TEST_ELEMENT_START_PATTERN}/ or
|
89
89
|
source_lines.empty?
|
90
90
|
|
91
91
|
@description << source_lines.first.strip
|
@@ -52,7 +52,7 @@ module CucumberAnalytics
|
|
52
52
|
File.open(@file, 'r') { |file| file_lines = file.readlines }
|
53
53
|
|
54
54
|
# collect feature tag lines
|
55
|
-
until file_lines.first =~
|
55
|
+
until file_lines.first =~ /^\s*Feature:/ or
|
56
56
|
file_lines.empty?
|
57
57
|
|
58
58
|
feature_lines << file_lines.first
|
@@ -60,7 +60,7 @@ module CucumberAnalytics
|
|
60
60
|
end
|
61
61
|
|
62
62
|
# collect everything else until the end of the feature section
|
63
|
-
until file_lines.first =~
|
63
|
+
until file_lines.first =~ /#{World::TEST_ELEMENT_START_PATTERN}/ or
|
64
64
|
file_lines.empty?
|
65
65
|
|
66
66
|
feature_lines << file_lines.first
|
@@ -4,6 +4,7 @@ module CucumberAnalytics
|
|
4
4
|
|
5
5
|
SANITARY_STRING = '___!!!___'
|
6
6
|
STEP_KEYWORD_PATTERN = '\s*(?:Given|When|Then|And|But|\*)\s*'
|
7
|
+
TEST_ELEMENT_START_PATTERN = '\s*(?:@|Background:|Scenario:|(?:Scenario Outline:))'
|
7
8
|
|
8
9
|
|
9
10
|
# Returns the left delimiter, which is used to mark the beginning of a step
|
@@ -56,6 +57,13 @@ module CucumberAnalytics
|
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
60
|
+
# Returns all directories found in the passed container.
|
61
|
+
def self.directories_in(container)
|
62
|
+
Array.new.tap do |accumulated_directories|
|
63
|
+
collect_directories(accumulated_directories, container)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
59
67
|
# Returns all feature files found in the passed container.
|
60
68
|
def self.files_in(container)
|
61
69
|
Array.new.tap do |accumulated_files|
|
@@ -134,6 +142,17 @@ module CucumberAnalytics
|
|
134
142
|
end
|
135
143
|
end
|
136
144
|
|
145
|
+
# Recursively gathers all directories found in the passed container.
|
146
|
+
def self.collect_directories(accumulated_directories, container)
|
147
|
+
accumulated_directories.concat container.feature_directories if container.respond_to?(:feature_directories)
|
148
|
+
|
149
|
+
if container.respond_to?(:contains)
|
150
|
+
container.contains.each do |child_container|
|
151
|
+
collect_directories(accumulated_directories, child_container)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
137
156
|
# Recursively gathers all feature files found in the passed container.
|
138
157
|
def self.collect_files(accumulated_files, container)
|
139
158
|
accumulated_files.concat container.feature_files if container.respond_to?(:feature_files)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_analytics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- README.rdoc
|
91
91
|
- Rakefile
|
92
92
|
- cucumber_analytics.gemspec
|
93
|
+
- features/analysis/directory_collection.feature
|
93
94
|
- features/analysis/feature_collection.feature
|
94
95
|
- features/analysis/feature_file_collection.feature
|
95
96
|
- features/analysis/step_collection.feature
|
@@ -164,6 +165,7 @@ specification_version: 3
|
|
164
165
|
summary: This gem provides an API to programmatically break down Cucumber feature
|
165
166
|
files so that they can be inspected and analyzed in a straightforward manner.
|
166
167
|
test_files:
|
168
|
+
- features/analysis/directory_collection.feature
|
167
169
|
- features/analysis/feature_collection.feature
|
168
170
|
- features/analysis/feature_file_collection.feature
|
169
171
|
- features/analysis/step_collection.feature
|