cucumber_analytics 0.0.6 → 0.0.7

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.
Files changed (37) hide show
  1. data/.simplecov +4 -0
  2. data/History.rdoc +9 -1
  3. data/Rakefile +12 -0
  4. data/cucumber_analytics.gemspec +4 -3
  5. data/features/analysis/feature_collection.feature +11 -7
  6. data/features/modeling/background_modeling.feature +9 -0
  7. data/features/modeling/directory_modeling.feature +9 -0
  8. data/features/modeling/example_modeling.feature +9 -1
  9. data/features/modeling/feature_file_modeling.feature +9 -0
  10. data/features/modeling/feature_modeling.feature +9 -0
  11. data/features/modeling/outline_modeling.feature +9 -0
  12. data/features/modeling/scenario_modeling.feature +9 -0
  13. data/features/step_definitions/spec_steps.rb +15 -0
  14. data/features/step_definitions/world_steps.rb +3 -2
  15. data/features/support/env.rb +3 -1
  16. data/lib/cucumber_analytics/feature_element.rb +1 -0
  17. data/lib/cucumber_analytics/logging.rb +6 -1
  18. data/lib/cucumber_analytics/outline_example.rb +6 -6
  19. data/lib/cucumber_analytics/parsed_directory.rb +15 -2
  20. data/lib/cucumber_analytics/parsed_feature.rb +1 -1
  21. data/lib/cucumber_analytics/parsed_file.rb +15 -3
  22. data/lib/cucumber_analytics/parsed_scenario.rb +6 -4
  23. data/lib/cucumber_analytics/parsed_scenario_outline.rb +7 -6
  24. data/lib/cucumber_analytics/step.rb +1 -0
  25. data/lib/cucumber_analytics/test_element.rb +14 -3
  26. data/lib/cucumber_analytics/version.rb +1 -1
  27. data/lib/cucumber_analytics/world.rb +1 -1
  28. data/spec/background_spec.rb +23 -0
  29. data/spec/directory_spec.rb +18 -0
  30. data/spec/example_spec.rb +37 -0
  31. data/spec/feature_spec.rb +20 -0
  32. data/spec/file_spec.rb +20 -0
  33. data/spec/outline_spec.rb +32 -0
  34. data/spec/scenario_spec.rb +33 -0
  35. data/spec/spec_helper.rb +27 -0
  36. data/spec/step_spec.rb +24 -0
  37. metadata +39 -2
data/.simplecov ADDED
@@ -0,0 +1,4 @@
1
+ SimpleCov.start do
2
+ root File.dirname(__FILE__)
3
+ merge_timeout 60
4
+ end
data/History.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ === Version 0.0.7 / 2013-02-01
2
+
3
+ * Bug fix: Feature collection no longer returns nil values for feature files
4
+ that do not contain features.
5
+ * Elements now know the element that contains them.
6
+ * Adjusted the default logging level so tht logging does not occur by default.
7
+
8
+
1
9
  === Version 0.0.6 / 2013-01-07
2
10
 
3
11
  * Improved support for example blocks in outlines.
@@ -7,7 +15,7 @@
7
15
 
8
16
  === Version 0.0.5 / 2012-12-16
9
17
 
10
- * Bug fix: a missing 'require' statement that was causing loading erros has
18
+ * Bug fix: a missing 'require' statement that was causing loading errors has
11
19
  been fixed.
12
20
 
13
21
 
data/Rakefile CHANGED
@@ -1,2 +1,14 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require 'cucumber/rake/task'
4
+ require 'rspec/core/rake_task'
5
+
6
+
7
+
8
+ desc 'Run all acceptance tests for the gem'
9
+ Cucumber::Rake::Task.new(:tests)
10
+
11
+ desc 'Run all API specifications for the gem'
12
+ RSpec::Core::RakeTask.new(:specs)
13
+
14
+ task :default => :tests
@@ -15,7 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = CucumberAnalytics::VERSION
17
17
 
18
- gem.add_development_dependency("rake")
19
- gem.add_development_dependency("cucumber")
20
- gem.add_development_dependency("simplecov")
18
+ gem.add_development_dependency('rake')
19
+ gem.add_development_dependency('cucumber')
20
+ gem.add_development_dependency('rspec')
21
+ gem.add_development_dependency('simplecov')
21
22
  end
@@ -14,13 +14,17 @@ Feature: Features can be collected from arbitrary parts of the codebase.
14
14
  """
15
15
  Feature: The test feature 1.
16
16
  """
17
+ And the following feature file "empty.feature":
18
+ """
19
+ """
17
20
  And the file "test_file_1.feature" is read
21
+ And the file "empty.feature" is read
18
22
  And a directory "feature_directory/nested_directory"
19
- And the following feature file "test_file_2.feature":
23
+ And the following feature file "test_file_3.feature":
20
24
  """
21
- Feature: The test feature 2.
25
+ Feature: The test feature 3.
22
26
  """
23
- And the file "test_file_2.feature" is read
27
+ And the file "test_file_3.feature" is read
24
28
  When the directory "feature_directory" is read
25
29
  And the directory "feature_directory/nested_directory" is read
26
30
 
@@ -28,12 +32,12 @@ Feature: Features can be collected from arbitrary parts of the codebase.
28
32
  Scenario: Features can be collected from files
29
33
  Then the features collected from file "1" are as follows:
30
34
  | The test feature 1. |
31
- Then the features collected from file "2" are as follows:
32
- | The test feature 2. |
35
+ Then the features collected from file "3" are as follows:
36
+ | The test feature 3. |
33
37
 
34
38
  Scenario: Features can be collected from directories
35
39
  Then the features collected from directory "1" are as follows:
36
40
  | The test feature 1. |
37
- | The test feature 2. |
41
+ | The test feature 3. |
38
42
  And the features collected from directory "2" are as follows:
39
- | The test feature 2. |
43
+ | The test feature 3. |
@@ -170,3 +170,12 @@ Feature: Background elements can be modeled.
170
170
  | '*' |
171
171
  | ' some more text' |
172
172
  | """ |
173
+
174
+ Scenario Outline: Background models pass all other specifications
175
+ Exact specifications detailing the API for Background models.
176
+ Given that there are "<additional specifications>" detailing models
177
+ When the corresponding unit tests are run
178
+ Then all of those specifications are met
179
+ Examples:
180
+ | additional specifications |
181
+ | background_spec.rb |
@@ -84,3 +84,12 @@ Feature: Directories can be modeled.
84
84
  And directory "2" feature files are as follows:
85
85
  | test_file_4.feature |
86
86
  | test_file_5.feature |
87
+
88
+ Scenario Outline: Directory models pass all other specifications
89
+ Exact specifications detailing the API for directory models.
90
+ Given that there are "<additional specifications>" detailing models
91
+ When the corresponding unit tests are run
92
+ Then all of those specifications are met
93
+ Examples:
94
+ | additional specifications |
95
+ | directory_spec.rb |
@@ -90,7 +90,6 @@ Feature: Example elements can be modeled.
90
90
  | param1 |
91
91
  And the test example block "3" has no parameters
92
92
 
93
-
94
93
  Scenario: The examples' rows are modeled.
95
94
  Then the test example block "1" rows are as follows:
96
95
  | x,y,? |
@@ -98,3 +97,12 @@ Feature: Example elements can be modeled.
98
97
  And the test example block "2" rows are as follows:
99
98
  | a |
100
99
  And the test example block "3" has no rows
100
+
101
+ Scenario Outline: Example models pass all other specifications
102
+ Exact specifications detailing the API for Examples models.
103
+ Given that there are "<additional specifications>" detailing models
104
+ When the corresponding unit tests are run
105
+ Then all of those specifications are met
106
+ Examples:
107
+ | additional specifications |
108
+ | example_spec.rb |
@@ -46,3 +46,12 @@ Feature: Feature files can be modeled.
46
46
  | path | path_to/why_would_you_make_an_empty_file.feature |
47
47
  | feature_count | 0 |
48
48
  And file "3" has no features
49
+
50
+ Scenario Outline: Feature file models pass all other specifications
51
+ Exact specifications detailing the API for .feature file models.
52
+ Given that there are "<additional specifications>" detailing models
53
+ When the corresponding unit tests are run
54
+ Then all of those specifications are met
55
+ Examples:
56
+ | additional specifications |
57
+ | file_spec.rb |
@@ -192,3 +192,12 @@ Feature: Features can be modeled.
192
192
  And feature "3" is found to have the following properties:
193
193
  | has_background? | false |
194
194
  And feature "3" has no background
195
+
196
+ Scenario Outline: Feature models pass all other specifications
197
+ Exact specifications detailing the API for Feature models.
198
+ Given that there are "<additional specifications>" detailing models
199
+ When the corresponding unit tests are run
200
+ Then all of those specifications are met
201
+ Examples:
202
+ | additional specifications |
203
+ | feature_spec.rb |
@@ -205,3 +205,12 @@ Feature: Scenario Outline elements can be modeled.
205
205
  And the test example blocks are as follows:
206
206
  | text describing the significance of the examples |
207
207
  | some examples with different significance and a tag |
208
+
209
+ Scenario Outline: Outline models pass all other specifications
210
+ Exact specifications detailing the API for Scenario Outline models.
211
+ Given that there are "<additional specifications>" detailing models
212
+ When the corresponding unit tests are run
213
+ Then all of those specifications are met
214
+ Examples:
215
+ | additional specifications |
216
+ | outline_spec.rb |
@@ -182,3 +182,12 @@ Feature: Scenario elements can be modeled.
182
182
  Scenario: The scenario applied tags are modeled.
183
183
  Then the test is found to have the following applied tags:
184
184
  | @a_feature_level_tag |
185
+
186
+ Scenario Outline: Scenario models pass all other specifications
187
+ Exact specifications detailing the API for Scenario models.
188
+ Given that there are "<additional specifications>" detailing models
189
+ When the corresponding unit tests are run
190
+ Then all of those specifications are met
191
+ Examples:
192
+ | additional specifications |
193
+ | scenario_spec.rb |
@@ -0,0 +1,15 @@
1
+ Given /^that there are "([^"]*)" detailing models$/ do |spec_file|
2
+ fail "The spec file does not exist: #{spec_file}" unless File.exists?(File.join(SPEC_DIRECTORY, spec_file))
3
+
4
+ @spec_file = spec_file
5
+ end
6
+
7
+ When /^the corresponding unit tests are run$/ do
8
+ command = "rspec spec/#{@spec_file}"
9
+
10
+ @specs_passed = system(command)
11
+ end
12
+
13
+ Then /^all of those specifications are met$/ do
14
+ fail "There were unmet specifications." unless @specs_passed
15
+ end
@@ -144,9 +144,10 @@ end
144
144
  Then /^the features collected from directory "([^"]*)" are as follows:$/ do |directory, features|
145
145
  directory ||= 1
146
146
 
147
- actual_features = CucumberAnalytics::World.features_in(@parsed_directories[directory - 1]).collect { |feature| feature.name }
147
+ expected = features.raw.flatten.sort
148
+ actual = CucumberAnalytics::World.features_in(@parsed_directories[directory - 1]).collect { |feature| feature.name }
148
149
 
149
- assert actual_features.flatten.sort == features.raw.flatten.sort
150
+ assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
150
151
  end
151
152
 
152
153
  Then /^the files collected from directory "([^"]*)" are as follows:$/ do |directory, files|
@@ -1,6 +1,6 @@
1
1
  unless RUBY_VERSION.to_s < '1.9.0'
2
2
  require 'simplecov'
3
- SimpleCov.start
3
+ SimpleCov.command_name('cucumber_tests')
4
4
  end
5
5
 
6
6
  include Test::Unit::Assertions
@@ -16,6 +16,8 @@ DEFAULT_FILE_DIRECTORY = "#{File.dirname(__FILE__)}/../temp_files"
16
16
  TEST_FILE_DIRECTORY = "#{File.dirname(__FILE__)}/../test_files"
17
17
  TEST_STEP_FILE_LOCATION = "#{DEFAULT_FILE_DIRECTORY}/#{DEFAULT_STEP_FILE_NAME}"
18
18
 
19
+ SPEC_DIRECTORY = "#{File.dirname(__FILE__)}/../../spec"
20
+
19
21
 
20
22
  Before do
21
23
  @default_feature_file_name = DEFAULT_FEATURE_FILE_NAME
@@ -4,6 +4,7 @@ module CucumberAnalytics
4
4
 
5
5
  attr_reader :name
6
6
  attr_reader :description
7
+ attr_accessor :parent_element
7
8
 
8
9
 
9
10
  # Creates a new FeatureElement object.
@@ -10,7 +10,12 @@ module CucumberAnalytics
10
10
  end
11
11
 
12
12
  def logger
13
- @logger ||= Logger.new('logfile.log')
13
+ unless @logger
14
+ @logger = Logger.new('logfile.log')
15
+ set_log_level(Logger::FATAL)
16
+ end
17
+
18
+ @logger
14
19
  end
15
20
 
16
21
  def logger=(new_logger)
@@ -5,7 +5,6 @@ module CucumberAnalytics
5
5
  attr_accessor :tags
6
6
  attr_accessor :rows
7
7
  attr_accessor :parameters
8
- attr_accessor :parent_element
9
8
 
10
9
 
11
10
  # Creates a new OutlineExample object and, if *source_lines* is provided,
@@ -13,9 +12,7 @@ module CucumberAnalytics
13
12
  def initialize(source_lines = nil)
14
13
  CucumberAnalytics::Logging.logger.info('OutlineExample#initialize')
15
14
  CucumberAnalytics::Logging.logger.debug('source lines')
16
- source_lines.each do |line|
17
- CucumberAnalytics::Logging.logger.debug(line.chomp)
18
- end
15
+ source_lines.each { |line| CucumberAnalytics::Logging.logger.debug(line.chomp) } if source_lines
19
16
 
20
17
  super
21
18
 
@@ -49,8 +46,7 @@ module CucumberAnalytics
49
46
  @rows.delete_at(location) if location
50
47
  end
51
48
 
52
- # Returns tags which are applicable to the example block which have been
53
- # inherited from the outline level.
49
+ # Returns tags which have been inherited from the outline level.
54
50
  def applied_tags
55
51
  additional_tags = @parent_element.tags
56
52
  additional_tags.concat(@parent_element.applied_tags) if @parent_element.respond_to?(:applied_tags)
@@ -58,6 +54,10 @@ module CucumberAnalytics
58
54
  additional_tags
59
55
  end
60
56
 
57
+ # Returns all tags which are applicable to the scenario.
58
+ def all_tags
59
+ applied_tags.concat(@tags)
60
+ end
61
61
 
62
62
  private
63
63
 
@@ -4,6 +4,7 @@ module CucumberAnalytics
4
4
 
5
5
  attr_reader :feature_files
6
6
  attr_reader :feature_directories
7
+ attr_accessor :parent_element
7
8
 
8
9
 
9
10
  # Creates a new ParsedDirectory object and, if *directory_parsed* is
@@ -51,8 +52,20 @@ module CucumberAnalytics
51
52
 
52
53
  entries.each do |entry|
53
54
  entry = @directory + '/' + entry
54
- @feature_directories << ParsedDirectory.new(entry) if File.directory?(entry)
55
- @feature_files << ParsedFile.new(entry) if entry =~ /\.feature$/
55
+
56
+ if File.directory?(entry)
57
+ found_directory = ParsedDirectory.new(entry)
58
+ found_directory.parent_element = self
59
+
60
+ @feature_directories << found_directory
61
+ end
62
+
63
+ if entry =~ /\.feature$/
64
+ found_feature_file = ParsedFile.new(entry)
65
+ found_feature_file.parent_element = self
66
+
67
+ @feature_files << found_feature_file
68
+ end
56
69
  end
57
70
  end
58
71
 
@@ -2,7 +2,7 @@ module CucumberAnalytics
2
2
  class ParsedFeature < FeatureElement
3
3
 
4
4
 
5
- attr_reader :tags
5
+ attr_accessor :tags
6
6
  attr_accessor :background
7
7
  attr_accessor :tests
8
8
 
@@ -3,6 +3,7 @@ module CucumberAnalytics
3
3
 
4
4
 
5
5
  attr_reader :feature
6
+ attr_accessor :parent_element
6
7
 
7
8
 
8
9
  # Creates a new ParsedFile object and, if *file_parsed* is provided,
@@ -26,7 +27,7 @@ module CucumberAnalytics
26
27
  # Returns the immediate child elements of the feature file(i.e. its
27
28
  # feature).
28
29
  def contains
29
- [@feature]
30
+ @feature ? [@feature] : []
30
31
  end
31
32
 
32
33
  # Returns the number of features contained in the file.
@@ -67,7 +68,15 @@ module CucumberAnalytics
67
68
  end
68
69
 
69
70
  # create a new feature bases on the collected lines
70
- @feature = feature_lines.empty? ? nil : ParsedFeature.new(feature_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
+
71
80
 
72
81
  if file_lines.first =~ /^\s*Background:/
73
82
 
@@ -92,7 +101,10 @@ module CucumberAnalytics
92
101
  end
93
102
 
94
103
  # create a new background based on the collected lines
95
- @feature.background = ParsedBackground.new(background_lines)
104
+ found_background = ParsedBackground.new(background_lines)
105
+ found_background.parent_element = @feature
106
+
107
+ @feature.background = found_background
96
108
  end
97
109
 
98
110
  parse_tests(file_lines)
@@ -3,7 +3,6 @@ module CucumberAnalytics
3
3
 
4
4
 
5
5
  attr_accessor :tags
6
- attr_accessor :parent_element
7
6
 
8
7
 
9
8
  # Creates a new ParsedScenario object and, if *source_lines* is provided,
@@ -11,9 +10,7 @@ module CucumberAnalytics
11
10
  def initialize(source_lines = nil)
12
11
  CucumberAnalytics::Logging.logger.info('ParsedScenario#initialize')
13
12
  CucumberAnalytics::Logging.logger.debug('source lines')
14
- source_lines.each do |line|
15
- CucumberAnalytics::Logging.logger.debug(line.chomp)
16
- end
13
+ source_lines.each { |line| CucumberAnalytics::Logging.logger.debug(line.chomp) } if source_lines
17
14
 
18
15
  super
19
16
 
@@ -31,6 +28,11 @@ module CucumberAnalytics
31
28
  additional_tags
32
29
  end
33
30
 
31
+ # Returns all tags which are applicable to the scenario.
32
+ def all_tags
33
+ applied_tags.concat(@tags)
34
+ end
35
+
34
36
 
35
37
  private
36
38
 
@@ -4,7 +4,6 @@ module CucumberAnalytics
4
4
 
5
5
  attr_accessor :tags
6
6
  attr_accessor :examples
7
- attr_accessor :parent_element
8
7
 
9
8
 
10
9
  # Creates a new ParsedScenarioOutline object and, if *source_lines* is
@@ -12,9 +11,7 @@ module CucumberAnalytics
12
11
  def initialize(source_lines = nil)
13
12
  CucumberAnalytics::Logging.logger.info('ParsedScenarioOutline#initialize')
14
13
  CucumberAnalytics::Logging.logger.debug('source lines')
15
- source_lines.each do |line|
16
- CucumberAnalytics::Logging.logger.debug(line.chomp)
17
- end
14
+ source_lines.each { |line| CucumberAnalytics::Logging.logger.debug(line.chomp) } if source_lines
18
15
 
19
16
  super
20
17
 
@@ -30,8 +27,7 @@ module CucumberAnalytics
30
27
  @examples
31
28
  end
32
29
 
33
- # Returns tags which are applicable to the outline which have been
34
- # inherited from the feature level.
30
+ # Returns tags which have been inherited from the feature level.
35
31
  def applied_tags
36
32
  additional_tags = @parent_element.tags
37
33
  additional_tags.concat(@parent_element.applied_tags) if @parent_element.respond_to?(:applied_tags)
@@ -39,6 +35,11 @@ module CucumberAnalytics
39
35
  additional_tags
40
36
  end
41
37
 
38
+ # Returns all tags which are applicable to the scenario.
39
+ def all_tags
40
+ applied_tags.concat(@tags)
41
+ end
42
+
42
43
 
43
44
  private
44
45
 
@@ -5,6 +5,7 @@ module CucumberAnalytics
5
5
  attr_reader :keyword
6
6
  attr_reader :base
7
7
  attr_reader :block
8
+ attr_accessor :parent_element
8
9
 
9
10
 
10
11
  # Creates a new Step object based on the passed string. If the optional
@@ -38,13 +38,24 @@ module CucumberAnalytics
38
38
  case
39
39
  when line =~ /^\s*"""/
40
40
  block = extract_doc_block(source_lines)
41
- @steps[@steps.size - 1] = Step.new(@steps.last.keyword + ' ' + @steps.last.base, block)
41
+
42
+ found_step = Step.new(@steps.last.keyword + ' ' + @steps.last.base, block)
43
+ found_step.parent_element = self
44
+
45
+ @steps[@steps.size - 1] = found_step
42
46
  when line =~ /^\s*\|/
43
47
  block = extract_table_block(source_lines)
44
- @steps[@steps.size - 1] = Step.new(@steps.last.keyword + ' ' + @steps.last.base, block)
48
+
49
+ found_step = Step.new(@steps.last.keyword + ' ' + @steps.last.base, block)
50
+ found_step.parent_element = self
51
+
52
+ @steps[@steps.size - 1] = found_step
45
53
  else
46
54
  unless World.ignored_line?(line)
47
- @steps << Step.new(line.strip)
55
+ found_step = Step.new(line.strip)
56
+ found_step.parent_element = self
57
+
58
+ @steps << found_step
48
59
  end
49
60
 
50
61
  source_lines.shift
@@ -1,3 +1,3 @@
1
1
  module CucumberAnalytics
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -147,7 +147,7 @@ module CucumberAnalytics
147
147
 
148
148
  # Recursively gathers all features found in the passed container.
149
149
  def self.collect_features(accumulated_features, container)
150
- accumulated_features << container.feature if container.respond_to?(:feature)
150
+ accumulated_features << container.feature if container.respond_to?(:feature) && container.feature
151
151
 
152
152
  if container.respond_to?(:contains)
153
153
  container.contains.each do |child_container|
@@ -0,0 +1,23 @@
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
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,37 @@
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
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('ParsedFeature') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe "ParsedFeature" 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
+ file = CucumberAnalytics::ParsedFile.new(file_path)
15
+ feature = file.feature
16
+
17
+ feature.parent_element.should equal file
18
+ end
19
+
20
+ end
data/spec/file_spec.rb ADDED
@@ -0,0 +1,20 @@
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
@@ -0,0 +1,32 @@
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
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('ParsedScenario') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe "ParsedScenario" do
6
+
7
+ it "knows all of its tags" do
8
+ feature = CucumberAnalytics::ParsedFeature.new
9
+ feature.tags = ['@feature_tag']
10
+ scenario = CucumberAnalytics::ParsedScenario.new
11
+ scenario.tags = ['@scenario_tag']
12
+
13
+ scenario.parent_element = feature
14
+ scenario.all_tags.sort.should == ['@feature_tag', '@scenario_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: Test scenario')
23
+ }
24
+
25
+ file = CucumberAnalytics::ParsedFile.new(file_path)
26
+
27
+ feature = file.feature
28
+ scenario = feature.tests.first
29
+
30
+ scenario.parent_element.should equal feature
31
+ end
32
+
33
+ end
@@ -0,0 +1,27 @@
1
+ require 'rspec'
2
+
3
+ require 'simplecov' unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ require "#{File.dirname(__FILE__)}/../lib/cucumber_analytics"
6
+
7
+ CucumberAnalytics::Logging.set_log_level(Logger::FATAL)
8
+
9
+
10
+ DEFAULT_FEATURE_FILE_NAME = 'test_feature.feature'
11
+ DEFAULT_FILE_DIRECTORY = "#{File.dirname(__FILE__)}/temp_files"
12
+
13
+
14
+ RSpec.configure do |config|
15
+ config.before(:all) do
16
+ @default_feature_file_name = DEFAULT_FEATURE_FILE_NAME
17
+ @default_file_directory = DEFAULT_FILE_DIRECTORY
18
+ end
19
+
20
+ config.before(:each) do
21
+ FileUtils.mkdir(@default_file_directory)
22
+ end
23
+
24
+ config.after(:each) do
25
+ FileUtils.remove_dir(@default_file_directory, true)
26
+ end
27
+ end
data/spec/step_spec.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Step') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Step' 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(' Scenario: Test scenario')
13
+ file.puts(' Given a test step')
14
+ }
15
+
16
+ file = CucumberAnalytics::ParsedFile.new(file_path)
17
+
18
+ scenario = file.feature.tests.first
19
+ step = scenario.steps.first
20
+
21
+ step.parent_element.should equal scenario
22
+ end
23
+
24
+ end
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.6
4
+ version: 0.0.7
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-01-07 00:00:00.000000000 Z
12
+ date: 2013-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
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'
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: simplecov
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +83,7 @@ extensions: []
67
83
  extra_rdoc_files: []
68
84
  files:
69
85
  - .gitignore
86
+ - .simplecov
70
87
  - Gemfile
71
88
  - History.rdoc
72
89
  - LICENSE
@@ -93,6 +110,7 @@ files:
93
110
  - features/step_definitions/file_steps.rb
94
111
  - features/step_definitions/outline_steps.rb
95
112
  - features/step_definitions/setup_steps.rb
113
+ - features/step_definitions/spec_steps.rb
96
114
  - features/step_definitions/test_steps.rb
97
115
  - features/step_definitions/world_steps.rb
98
116
  - features/support/env.rb
@@ -111,6 +129,15 @@ files:
111
129
  - lib/cucumber_analytics/test_element.rb
112
130
  - lib/cucumber_analytics/version.rb
113
131
  - lib/cucumber_analytics/world.rb
132
+ - spec/background_spec.rb
133
+ - spec/directory_spec.rb
134
+ - spec/example_spec.rb
135
+ - spec/feature_spec.rb
136
+ - spec/file_spec.rb
137
+ - spec/outline_spec.rb
138
+ - spec/scenario_spec.rb
139
+ - spec/spec_helper.rb
140
+ - spec/step_spec.rb
114
141
  homepage: https://github.com/enkessler/cucumber_analytics
115
142
  licenses: []
116
143
  post_install_message:
@@ -157,8 +184,18 @@ test_files:
157
184
  - features/step_definitions/file_steps.rb
158
185
  - features/step_definitions/outline_steps.rb
159
186
  - features/step_definitions/setup_steps.rb
187
+ - features/step_definitions/spec_steps.rb
160
188
  - features/step_definitions/test_steps.rb
161
189
  - features/step_definitions/world_steps.rb
162
190
  - features/support/env.rb
163
191
  - features/support/transforms.rb
192
+ - spec/background_spec.rb
193
+ - spec/directory_spec.rb
194
+ - spec/example_spec.rb
195
+ - spec/feature_spec.rb
196
+ - spec/file_spec.rb
197
+ - spec/outline_spec.rb
198
+ - spec/scenario_spec.rb
199
+ - spec/spec_helper.rb
200
+ - spec/step_spec.rb
164
201
  has_rdoc: