cucumber_analytics 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.rdoc +76 -0
  5. data/Rakefile +2 -0
  6. data/cucumber_analytics.gemspec +22 -0
  7. data/features/analysis/feature_collection.feature +39 -0
  8. data/features/analysis/feature_file_collection.feature +36 -0
  9. data/features/analysis/step_collection.feature +137 -0
  10. data/features/analysis/tag_collection.feature +91 -0
  11. data/features/analysis/test_collection.feature +69 -0
  12. data/features/analysis/test_comparison.feature +123 -0
  13. data/features/modeling/background_modeling.feature +147 -0
  14. data/features/modeling/directory_modeling.feature +86 -0
  15. data/features/modeling/feature_file_modeling.feature +37 -0
  16. data/features/modeling/feature_modeling.feature +163 -0
  17. data/features/modeling/outline_modeling.feature +186 -0
  18. data/features/modeling/scenario_modeling.feature +154 -0
  19. data/features/step_definitions/background_steps.rb +55 -0
  20. data/features/step_definitions/directory_steps.rb +20 -0
  21. data/features/step_definitions/feature_steps.rb +62 -0
  22. data/features/step_definitions/file_steps.rb +18 -0
  23. data/features/step_definitions/outline_steps.rb +26 -0
  24. data/features/step_definitions/setup_steps.rb +50 -0
  25. data/features/step_definitions/test_steps.rb +82 -0
  26. data/features/step_definitions/world_steps.rb +158 -0
  27. data/features/support/env.rb +29 -0
  28. data/features/support/transforms.rb +3 -0
  29. data/lib/cucumber_analytics/feature_element.rb +54 -0
  30. data/lib/cucumber_analytics/outline_example.rb +31 -0
  31. data/lib/cucumber_analytics/parsed_background.rb +23 -0
  32. data/lib/cucumber_analytics/parsed_directory.rb +56 -0
  33. data/lib/cucumber_analytics/parsed_feature.rb +70 -0
  34. data/lib/cucumber_analytics/parsed_file.rb +140 -0
  35. data/lib/cucumber_analytics/parsed_scenario.rb +29 -0
  36. data/lib/cucumber_analytics/parsed_scenario_outline.rb +57 -0
  37. data/lib/cucumber_analytics/step.rb +81 -0
  38. data/lib/cucumber_analytics/test_element.rb +93 -0
  39. data/lib/cucumber_analytics/version.rb +3 -0
  40. data/lib/cucumber_analytics/world.rb +182 -0
  41. data/lib/cucumber_analytics.rb +12 -0
  42. metadata +174 -0
@@ -0,0 +1,182 @@
1
+ module CucumberAnalytics
2
+ module World
3
+
4
+
5
+ SANITARY_STRING = '___!!!___'
6
+ STEP_KEYWORD_PATTERN = '\s*(?:Given|When|Then|And|\*)\s*'
7
+
8
+
9
+ # Returns the left delimiter, which is used to mark the beginning of a step
10
+ # argument.
11
+ def self.left_delimiter
12
+ @left_delimiter || @right_delimiter
13
+ end
14
+
15
+ # Sets the left delimiter that will be used by default when determining
16
+ # step arguments.
17
+ def self.left_delimiter=(new_delimiter)
18
+ @left_delimiter = new_delimiter
19
+ end
20
+
21
+ # Returns the right delimiter, which is used to mark the end of a step
22
+ # argument.
23
+ def self.right_delimiter
24
+ @right_delimiter || @left_delimiter
25
+ end
26
+
27
+ # Sets the right delimiter that will be used by default when determining
28
+ # step arguments.
29
+ def self.right_delimiter=(new_delimiter)
30
+ @right_delimiter = new_delimiter
31
+ end
32
+
33
+ # Loads the step patterns contained in the given file into the World.
34
+ def self.load_step_file(file_path)
35
+ @@defined_expressions ||= []
36
+
37
+ File.open(file_path, 'r') do |file|
38
+ file.readlines.each do |line|
39
+ if step_def_line?(line)
40
+ the_reg_ex = extract_regular_expression(line)
41
+ @@defined_expressions << the_reg_ex
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ # Returns the step patterns that have been loaded into the World.
48
+ def self.defined_step_patterns
49
+ @@defined_expressions
50
+ end
51
+
52
+ # Returns all tags found in the passed container.
53
+ def self.tags_in(container)
54
+ Array.new.tap do |accumulated_tags|
55
+ collect_tags(accumulated_tags, container)
56
+ end
57
+ end
58
+
59
+ # Returns all feature files found in the passed container.
60
+ def self.files_in(container)
61
+ Array.new.tap do |accumulated_files|
62
+ collect_files(accumulated_files, container)
63
+ end
64
+ end
65
+
66
+ # Returns all features found in the passed container.
67
+ def self.features_in(container)
68
+ Array.new.tap do |accumulated_features|
69
+ collect_features(accumulated_features, container)
70
+ end
71
+ end
72
+
73
+ # Returns all tests found in the passed container.
74
+ def self.tests_in(container)
75
+ Array.new.tap do |accumulated_tests|
76
+ collect_tests(accumulated_tests, container)
77
+ end
78
+ end
79
+
80
+ # Returns all steps found in the passed container.
81
+ def self.steps_in(container)
82
+ Array.new.tap do |accumulated_steps|
83
+ collect_steps(accumulated_steps, container)
84
+ end
85
+ end
86
+
87
+ # Returns all undefined steps found in the passed container.
88
+ def self.undefined_steps_in(container)
89
+ all_steps = steps_in(container)
90
+
91
+ all_steps.select { |step| !World.defined_step_patterns.any? { |pattern| step.base =~ Regexp.new(pattern) } }
92
+ end
93
+
94
+ # Returns all defined steps found in the passed container.
95
+ def self.defined_steps_in(container)
96
+ all_steps = steps_in(container)
97
+
98
+ all_steps.select { |step| World.defined_step_patterns.any? { |pattern| step.base =~ Regexp.new(pattern) } }
99
+ end
100
+
101
+
102
+ private
103
+
104
+
105
+ # Make life easier by ensuring that the only forward slashes in the
106
+ # regular expression are the important ones.
107
+ def self.sanitize_line(line)
108
+ line.gsub('\/', SANITARY_STRING)
109
+ end
110
+
111
+ # And be sure to restore the line to its original state.
112
+ def self.desanitize_line(line)
113
+ line.gsub(SANITARY_STRING, '\/')
114
+ end
115
+
116
+ # Returns whether or not the passed line is a step pattern.
117
+ def self.step_def_line?(line)
118
+ !!(sanitize_line(line) =~ /^#{World::STEP_KEYWORD_PATTERN}\/[^\/]*\//)
119
+ end
120
+
121
+ # Returns the regular expression portion of a step pattern line.
122
+ def self.extract_regular_expression(line)
123
+ desanitize_line(sanitize_line(line).match(/^#{World::STEP_KEYWORD_PATTERN}\/([^\/]*)\//)[1])
124
+ end
125
+
126
+ # Recursively gathers all tags found in the passed container.
127
+ def self.collect_tags(accumulated_tags, container)
128
+ accumulated_tags.concat container.tags if container.respond_to?(:tags)
129
+
130
+ if container.respond_to?(:contains)
131
+ container.contains.each do |child_container|
132
+ collect_tags(accumulated_tags, child_container)
133
+ end
134
+ end
135
+ end
136
+
137
+ # Recursively gathers all feature files found in the passed container.
138
+ def self.collect_files(accumulated_files, container)
139
+ accumulated_files.concat container.feature_files if container.respond_to?(:feature_files)
140
+
141
+ if container.respond_to?(:contains)
142
+ container.contains.each do |child_container|
143
+ collect_files(accumulated_files, child_container)
144
+ end
145
+ end
146
+ end
147
+
148
+ # Recursively gathers all features found in the passed container.
149
+ def self.collect_features(accumulated_features, container)
150
+ accumulated_features << container.feature if container.respond_to?(:feature)
151
+
152
+ if container.respond_to?(:contains)
153
+ container.contains.each do |child_container|
154
+ collect_features(accumulated_features, child_container)
155
+ end
156
+ end
157
+ end
158
+
159
+ # Recursively gathers all tests found in the passed container.
160
+ def self.collect_tests(accumulated_tests, container)
161
+ accumulated_tests.concat container.tests if container.respond_to?(:tests)
162
+
163
+ if container.respond_to?(:contains)
164
+ container.contains.each do |child_container|
165
+ collect_tests(accumulated_tests, child_container)
166
+ end
167
+ end
168
+ end
169
+
170
+ # Recursively gathers all steps found in the passed container.
171
+ def self.collect_steps(accumulated_steps, container)
172
+ accumulated_steps.concat container.steps if container.respond_to?(:steps)
173
+
174
+ if container.respond_to?(:contains)
175
+ container.contains.each do |child_container|
176
+ collect_steps(accumulated_steps, child_container)
177
+ end
178
+ end
179
+ end
180
+
181
+ end
182
+ end
@@ -0,0 +1,12 @@
1
+ require 'cucumber_analytics/version'
2
+ require 'cucumber_analytics/parsed_file'
3
+ require 'cucumber_analytics/parsed_directory'
4
+ require 'cucumber_analytics/feature_element.rb'
5
+ require 'cucumber_analytics/parsed_feature'
6
+ require 'cucumber_analytics/test_element.rb'
7
+ require 'cucumber_analytics/parsed_background'
8
+ require 'cucumber_analytics/parsed_scenario'
9
+ require 'cucumber_analytics/parsed_scenario_outline'
10
+ require 'cucumber_analytics/outline_example'
11
+ require 'cucumber_analytics/step'
12
+ require 'cucumber_analytics/world'
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber_analytics
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Eric Kessler
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: cucumber
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: wrong
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: simplecov
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Static analysis of Cucumber tests made easy.
79
+ email:
80
+ - morrow748@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - Gemfile
87
+ - LICENSE
88
+ - README.rdoc
89
+ - Rakefile
90
+ - cucumber_analytics.gemspec
91
+ - features/analysis/feature_collection.feature
92
+ - features/analysis/feature_file_collection.feature
93
+ - features/analysis/step_collection.feature
94
+ - features/analysis/tag_collection.feature
95
+ - features/analysis/test_collection.feature
96
+ - features/analysis/test_comparison.feature
97
+ - features/modeling/background_modeling.feature
98
+ - features/modeling/directory_modeling.feature
99
+ - features/modeling/feature_file_modeling.feature
100
+ - features/modeling/feature_modeling.feature
101
+ - features/modeling/outline_modeling.feature
102
+ - features/modeling/scenario_modeling.feature
103
+ - features/step_definitions/background_steps.rb
104
+ - features/step_definitions/directory_steps.rb
105
+ - features/step_definitions/feature_steps.rb
106
+ - features/step_definitions/file_steps.rb
107
+ - features/step_definitions/outline_steps.rb
108
+ - features/step_definitions/setup_steps.rb
109
+ - features/step_definitions/test_steps.rb
110
+ - features/step_definitions/world_steps.rb
111
+ - features/support/env.rb
112
+ - features/support/transforms.rb
113
+ - lib/cucumber_analytics.rb
114
+ - lib/cucumber_analytics/feature_element.rb
115
+ - lib/cucumber_analytics/outline_example.rb
116
+ - lib/cucumber_analytics/parsed_background.rb
117
+ - lib/cucumber_analytics/parsed_directory.rb
118
+ - lib/cucumber_analytics/parsed_feature.rb
119
+ - lib/cucumber_analytics/parsed_file.rb
120
+ - lib/cucumber_analytics/parsed_scenario.rb
121
+ - lib/cucumber_analytics/parsed_scenario_outline.rb
122
+ - lib/cucumber_analytics/step.rb
123
+ - lib/cucumber_analytics/test_element.rb
124
+ - lib/cucumber_analytics/version.rb
125
+ - lib/cucumber_analytics/world.rb
126
+ homepage: https://github.com/enkessler/cucumber_analytics
127
+ licenses: []
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 1.8.24
147
+ signing_key:
148
+ specification_version: 3
149
+ summary: This gem provides an API to programmatically break down Cucumber feature
150
+ files so that they can be inspected and analyzed in a straightforward manner.
151
+ test_files:
152
+ - features/analysis/feature_collection.feature
153
+ - features/analysis/feature_file_collection.feature
154
+ - features/analysis/step_collection.feature
155
+ - features/analysis/tag_collection.feature
156
+ - features/analysis/test_collection.feature
157
+ - features/analysis/test_comparison.feature
158
+ - features/modeling/background_modeling.feature
159
+ - features/modeling/directory_modeling.feature
160
+ - features/modeling/feature_file_modeling.feature
161
+ - features/modeling/feature_modeling.feature
162
+ - features/modeling/outline_modeling.feature
163
+ - features/modeling/scenario_modeling.feature
164
+ - features/step_definitions/background_steps.rb
165
+ - features/step_definitions/directory_steps.rb
166
+ - features/step_definitions/feature_steps.rb
167
+ - features/step_definitions/file_steps.rb
168
+ - features/step_definitions/outline_steps.rb
169
+ - features/step_definitions/setup_steps.rb
170
+ - features/step_definitions/test_steps.rb
171
+ - features/step_definitions/world_steps.rb
172
+ - features/support/env.rb
173
+ - features/support/transforms.rb
174
+ has_rdoc: