cucumber_analytics 1.2.0 → 1.3.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.
Files changed (40) hide show
  1. checksums.yaml +8 -8
  2. data/History.rdoc +7 -2
  3. data/README.rdoc +3 -3
  4. data/cucumber_analytics.gemspec +2 -0
  5. data/features/modeling/doc_string_modeling.feature +3 -2
  6. data/features/modeling/tag_modeling.feature +1 -0
  7. data/lib/cucumber_analytics/directory.rb +1 -3
  8. data/lib/cucumber_analytics/doc_string.rb +1 -3
  9. data/lib/cucumber_analytics/feature_element.rb +1 -3
  10. data/lib/cucumber_analytics/feature_file.rb +1 -3
  11. data/lib/cucumber_analytics/nested.rb +33 -0
  12. data/lib/cucumber_analytics/row.rb +1 -3
  13. data/lib/cucumber_analytics/step.rb +1 -3
  14. data/lib/cucumber_analytics/table.rb +1 -3
  15. data/lib/cucumber_analytics/tag.rb +1 -3
  16. data/lib/cucumber_analytics/version.rb +1 -1
  17. data/lib/cucumber_analytics.rb +1 -0
  18. data/spec/integration/background_integration_spec.rb +42 -0
  19. data/spec/integration/directory_integration_spec.rb +24 -0
  20. data/spec/integration/doc_string_integration_spec.rb +66 -0
  21. data/spec/integration/example_integration_spec.rb +50 -0
  22. data/spec/integration/feature_file_integration_spec.rb +24 -0
  23. data/spec/integration/feature_integration_spec.rb +34 -0
  24. data/spec/integration/outline_integration_spec.rb +45 -0
  25. data/spec/integration/scenario_integration_spec.rb +43 -0
  26. data/spec/integration/step_integration_spec.rb +79 -31
  27. data/spec/integration/tag_integration_spec.rb +67 -0
  28. data/spec/unit/background_unit_spec.rb +5 -2
  29. data/spec/unit/doc_string_unit_spec.rb +4 -1
  30. data/spec/unit/example_unit_spec.rb +5 -2
  31. data/spec/unit/feature_unit_spec.rb +5 -2
  32. data/spec/unit/nested_element_unit_specs.rb +18 -6
  33. data/spec/unit/nested_unit_spec.rb +37 -0
  34. data/spec/unit/outline_unit_spec.rb +5 -2
  35. data/spec/unit/row_unit_spec.rb +4 -1
  36. data/spec/unit/scenario_unit_spec.rb +5 -2
  37. data/spec/unit/step_unit_spec.rb +5 -2
  38. data/spec/unit/table_unit_spec.rb +4 -1
  39. data/spec/unit/world_unit_spec.rb +4 -3
  40. metadata +11 -3
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTM1OWIzMGY3Yjk5MTY5ZGUxZmM1ODFlNjJmMTlkZjM2MGNlOTljZA==
4
+ NzFmZGE0MWM0NzI0MmQ2NWMxYWM3MmI1YWRlMjIwYThjNTAwMWIzZg==
5
5
  data.tar.gz: !binary |-
6
- OGIxYzY2MWNjMTk2NzMyNjJlMzU2NjgxZjVlNWVlMmQyNDg3NDRiMQ==
6
+ NDkzOWY5ODZkNjY5MWVhN2Q1ZGViM2VlMTkxN2EyNDY5M2Y0ODA2OQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NGU1ZDU5NDc0NDVkNjAxNmNjZWZmM2RiODE2YzhiNmMyNjE5NGRiMjhjYjQ1
10
- YjkwMmJkZWYzMjBmNzUwZTg5ZmE0NmZkMTQ3MGUzZjVmYWRjNDk5MTk3NDUx
11
- OWZiNDgxNjU2ZDI0MmJiNjczMmE2OGFmZGI4ZWU1YzkwOTUyYTM=
9
+ ZGM5Mjc0ZTEwODZlMmViM2I2M2NiYmEzZDM3NzhhNmVkZmI4ZTMwY2IwZjhm
10
+ N2U1ZDAyYjg0OWJiN2U3ZDM2OTE4MjliM2U1MzdjZmFmM2UyMDFjNjlhNmI2
11
+ NDQxY2ZmZDUxZjIyMzYzOGU5M2FlYTUxZDFjZWNjYWQ1ZmRlMzE=
12
12
  data.tar.gz: !binary |-
13
- NjgzZTRiYzU1N2M1ZjIxZWQ2OTJiN2I1MzZlMTNkZjE4YjA5ZjM0NDUxNDRk
14
- NmFhYTExNTE4MzYzNTJkNGQ4NGQxZjExYjMzMzZiNjRmZWJlY2NhNThjOTY0
15
- YmMzYzRmMThlMTY0YjhkNjczOTk3NjM5MTA1ZWVmYTU5Y2Q4ZDM=
13
+ ODBjNDRmN2JjOWY3ZGJlYmE0YWI5ZWJhMDkzNzAyMGRlM2IxOTJkMmMyNTk2
14
+ YjM1NzRiYjkyNzgzZDFiZWRhMGYxZTgzNGY0M2VjYzBiM2Y2MzQ5ZGE5Y2Vk
15
+ MjU3YTM0NmQ1NmMxYzQ5YzYzZjQ1ZjdjNzY3NjE2NGZiYjlhYTM=
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ === Version 1.3.0 / 2013-10-02
2
+
3
+ * Elements now have a convenience method for accessing their ancestor elements.
4
+
5
+
1
6
  === Version 1.2.0 / 2013-09-01
2
7
 
3
8
  * Bug fix: nil no longer shows up as a child element of a Feature if the Feature
@@ -81,9 +86,9 @@
81
86
  === Version 0.0.3 / 2012-11-10
82
87
 
83
88
  * 'But' has been added to the list of recognized step keywords (formerly Given,
84
- When,Then, And, and *).
89
+ When,Then, And, and *).
85
90
  * Bug fix: the number of test cases a feature is considered to contain now
86
- properly takes into account an outline's example rows.
91
+ properly takes into account an outline's example rows.
87
92
 
88
93
 
89
94
  === Version 0.0.2 / 2012-11-01
data/README.rdoc CHANGED
@@ -67,10 +67,10 @@ also discovered that our team is creating several redundant steps that could be
67
67
  rewritten into a single, reusable step.
68
68
 
69
69
 
70
- ===Other usages
71
-
72
- https://gist.github.com/enkessler/6408879 - Creating a step lexicon
70
+ === Other usages
73
71
 
72
+ * https://gist.github.com/enkessler/6408879 - Creating a step lexicon
73
+ * https://gist.github.com/enkessler/6519022 - Creating unique identifiers for all test cases
74
74
 
75
75
  == Contributing
76
76
 
@@ -8,6 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.summary = %q{This gem provides an API to programmatically break down Cucumber feature files so that they can be inspected and analyzed in a straightforward manner.}
9
9
  gem.homepage = 'https://github.com/enkessler/cucumber_analytics'
10
10
 
11
+ gem.license = 'MIT'
12
+
11
13
  gem.files = `git ls-files`.split($\)
12
14
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -46,5 +46,6 @@ Feature: Doc String elements can be modeled.
46
46
  When the corresponding specifications are run
47
47
  Then all of those specifications are met
48
48
  Examples:
49
- | additional specifications |
50
- | doc_string_unit_spec.rb |
49
+ | additional specifications |
50
+ | doc_string_unit_spec.rb |
51
+ | doc_string_integration_spec.rb |
@@ -49,3 +49,4 @@ Feature: Tag elements can be modeled.
49
49
  Examples:
50
50
  | additional specifications |
51
51
  | tag_unit_spec.rb |
52
+ | tag_integration_spec.rb |
@@ -5,6 +5,7 @@ module CucumberAnalytics
5
5
  class Directory
6
6
 
7
7
  include Containing
8
+ include Nested
8
9
 
9
10
 
10
11
  # The FeatureFile objects contained by the Directory
@@ -13,9 +14,6 @@ module CucumberAnalytics
13
14
  # The Directory objects contained by the Directory
14
15
  attr_accessor :directories
15
16
 
16
- # The parent object that contains *self*
17
- attr_accessor :parent_element
18
-
19
17
 
20
18
  # Creates a new Directory object and, if *directory_parsed* is provided,
21
19
  # populates the object.
@@ -5,11 +5,9 @@ module CucumberAnalytics
5
5
  class DocString
6
6
 
7
7
  include Raw
8
+ include Nested
8
9
 
9
10
 
10
- # The parent object that contains *self*
11
- attr_accessor :parent_element
12
-
13
11
  # The content type associated with the doc string
14
12
  attr_accessor :content_type
15
13
 
@@ -6,6 +6,7 @@ module CucumberAnalytics
6
6
 
7
7
  include Sourceable
8
8
  include Raw
9
+ include Nested
9
10
 
10
11
 
11
12
  # The name of the FeatureElement
@@ -14,9 +15,6 @@ module CucumberAnalytics
14
15
  # The description of the FeatureElement
15
16
  attr_accessor :description
16
17
 
17
- # The parent object that contains *self*
18
- attr_accessor :parent_element
19
-
20
18
 
21
19
  # Creates a new FeatureElement object and, if *parsed_element* is provided,
22
20
  # populates the object.
@@ -5,14 +5,12 @@ module CucumberAnalytics
5
5
  class FeatureFile
6
6
 
7
7
  include Containing
8
+ include Nested
8
9
 
9
10
 
10
11
  # The Feature objects contained by the FeatureFile
11
12
  attr_accessor :features
12
13
 
13
- # The parent object that contains *self*
14
- attr_accessor :parent_element
15
-
16
14
 
17
15
  # Creates a new FeatureFile object and, if *file_parsed* is provided,
18
16
  # populates the object.
@@ -0,0 +1,33 @@
1
+ module CucumberAnalytics
2
+
3
+ # A mix-in module containing methods used by elements that are nested inside
4
+ # of other elements.
5
+
6
+ module Nested
7
+
8
+ # The parent object that contains *self*
9
+ attr_accessor :parent_element
10
+
11
+
12
+ # Returns the ancestor of *self* that matches the given type.
13
+ def get_ancestor(ancestor_type)
14
+ ancestor = self.parent_element
15
+ target_type = {:directory => Directory,
16
+ :feature_file => FeatureFile,
17
+ :feature => Feature,
18
+ :test => TestElement,
19
+ :step => Step,
20
+ :example => Example
21
+ }[ancestor_type]
22
+
23
+ raise(ArgumentError, "Unknown ancestor type '#{ancestor_type}'.") if target_type.nil?
24
+
25
+ until ancestor.is_a?(target_type) || ancestor.nil?
26
+ ancestor = ancestor.parent_element
27
+ end
28
+
29
+ ancestor
30
+ end
31
+
32
+ end
33
+ end
@@ -6,11 +6,9 @@ module CucumberAnalytics
6
6
 
7
7
  include Sourceable
8
8
  include Raw
9
+ include Nested
9
10
 
10
11
 
11
- # The parent object that contains *self*
12
- attr_accessor :parent_element
13
-
14
12
  # The cells that make up the row
15
13
  attr_accessor :cells
16
14
 
@@ -7,6 +7,7 @@ module CucumberAnalytics
7
7
  include Containing
8
8
  include Sourceable
9
9
  include Raw
10
+ include Nested
10
11
 
11
12
 
12
13
  # The step's keyword
@@ -18,9 +19,6 @@ module CucumberAnalytics
18
19
  # The step's passed block
19
20
  attr_accessor :block
20
21
 
21
- # The parent object that contains *self*
22
- attr_accessor :parent_element
23
-
24
22
  # The step's arguments
25
23
  attr_accessor :arguments
26
24
 
@@ -5,11 +5,9 @@ module CucumberAnalytics
5
5
  class Table
6
6
 
7
7
  include Raw
8
+ include Nested
8
9
 
9
10
 
10
- # The parent object that contains *self*
11
- attr_accessor :parent_element
12
-
13
11
  # The contents of the table
14
12
  attr_accessor :contents
15
13
 
@@ -6,11 +6,9 @@ module CucumberAnalytics
6
6
 
7
7
  include Raw
8
8
  include Sourceable
9
+ include Nested
9
10
 
10
11
 
11
- # The parent object that contains *self*
12
- attr_accessor :parent_element
13
-
14
12
  # The name of the Tag
15
13
  attr_accessor :name
16
14
 
@@ -1,3 +1,3 @@
1
1
  module CucumberAnalytics
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -4,6 +4,7 @@ require 'cucumber_analytics/containing'
4
4
  require 'cucumber_analytics/taggable'
5
5
  require 'cucumber_analytics/raw'
6
6
  require 'cucumber_analytics/sourceable'
7
+ require 'cucumber_analytics/nested'
7
8
  require 'cucumber_analytics/feature_file'
8
9
  require 'cucumber_analytics/directory'
9
10
  require 'cucumber_analytics/feature_element.rb'
@@ -15,4 +15,46 @@ describe 'Background, Integration' do
15
15
  step.parent_element.should equal background
16
16
  end
17
17
 
18
+ context 'getting stuff' do
19
+
20
+ before(:each) do
21
+ source = ['Feature: Test feature',
22
+ '',
23
+ ' Background: Test background',
24
+ ' * a step:']
25
+ source = source.join("\n")
26
+
27
+ file_path = "#{@default_file_directory}/background_test_file.feature"
28
+ File.open(file_path, 'w') { |file| file.write(source) }
29
+
30
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
31
+ @background = @directory.feature_files.first.features.first.background
32
+ end
33
+
34
+
35
+ it 'can get its directory' do
36
+ directory = @background.get_ancestor(:directory)
37
+
38
+ directory.path.should == @directory.path
39
+ end
40
+
41
+ it 'can get its feature file' do
42
+ feature_file = @background.get_ancestor(:feature_file)
43
+
44
+ feature_file.path.should == @directory.feature_files.first.path
45
+ end
46
+
47
+ it 'can get its feature' do
48
+ feature = @background.get_ancestor(:feature)
49
+
50
+ feature.name.should == @directory.feature_files.first.features.first.name
51
+ end
52
+
53
+ it 'returns nil if it does not have the requested type of ancestor' do
54
+ example = @background.get_ancestor(:example)
55
+
56
+ example.should be_nil
57
+ end
58
+
59
+ end
18
60
  end
@@ -21,4 +21,28 @@ describe 'Directory, Integration' do
21
21
  file.parent_element.should equal directory
22
22
  end
23
23
 
24
+ context 'getting stuff' do
25
+
26
+ before(:each) do
27
+ nested_directory = "#{@default_file_directory}/nested_directory"
28
+ FileUtils.mkdir(nested_directory)
29
+
30
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
31
+ @nested_directory = @directory.directories.first
32
+ end
33
+
34
+
35
+ it 'can get its directory' do
36
+ directory = @nested_directory.get_ancestor(:directory)
37
+
38
+ directory.path.should == @directory.path
39
+ end
40
+
41
+ it 'returns nil if it does not have the requested type of ancestor' do
42
+ example = @nested_directory.get_ancestor(:example)
43
+
44
+ example.should be_nil
45
+ end
46
+
47
+ end
24
48
  end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('DocString') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'DocString, Integration' do
6
+
7
+ context 'getting stuff' do
8
+
9
+ before(:each) do
10
+ source = ['Feature: Test feature',
11
+ '',
12
+ ' Scenario: Test test',
13
+ ' * a big step:',
14
+ ' """',
15
+ ' a',
16
+ ' doc',
17
+ ' string',
18
+ ' """']
19
+ source = source.join("\n")
20
+
21
+ file_path = "#{@default_file_directory}/doc_string_test_file.feature"
22
+ File.open(file_path, 'w') { |file| file.write(source) }
23
+
24
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
25
+ @doc_string = @directory.feature_files.first.features.first.tests.first.steps.first.block
26
+ end
27
+
28
+
29
+ it 'can get its directory' do
30
+ directory = @doc_string.get_ancestor(:directory)
31
+
32
+ directory.path.should == @directory.path
33
+ end
34
+
35
+ it 'can get its feature file' do
36
+ feature_file = @doc_string.get_ancestor(:feature_file)
37
+
38
+ feature_file.path.should == @directory.feature_files.first.path
39
+ end
40
+
41
+ it 'can get its feature' do
42
+ feature = @doc_string.get_ancestor(:feature)
43
+
44
+ feature.name.should == @directory.feature_files.first.features.first.name
45
+ end
46
+
47
+ it 'can get its test' do
48
+ test = @doc_string.get_ancestor(:test)
49
+
50
+ test.name.should == @directory.feature_files.first.features.first.tests.first.name
51
+ end
52
+
53
+ it 'can get its step' do
54
+ step = @doc_string.get_ancestor(:step)
55
+
56
+ step.base.should == @directory.feature_files.first.features.first.tests.first.steps.first.base
57
+ end
58
+
59
+ it 'returns nil if it does not have the requested type of ancestor' do
60
+ example = @doc_string.get_ancestor(:example)
61
+
62
+ example.should be_nil
63
+ end
64
+
65
+ end
66
+ end
@@ -20,4 +20,54 @@ describe 'Example, Integration' do
20
20
  tag.parent_element.should equal example
21
21
  end
22
22
 
23
+ context 'getting stuff' do
24
+
25
+ before(:each) do
26
+ source = ['Feature: Test feature',
27
+ '',
28
+ ' Scenario Outline: Test test',
29
+ ' * a step',
30
+ ' Examples: Test example',
31
+ ' | a param |']
32
+ source = source.join("\n")
33
+
34
+ file_path = "#{@default_file_directory}/example_test_file.feature"
35
+ File.open(file_path, 'w') { |file| file.write(source) }
36
+
37
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
38
+ @example = @directory.feature_files.first.features.first.tests.first.examples.first
39
+ end
40
+
41
+
42
+ it 'can get its directory' do
43
+ directory = @example.get_ancestor(:directory)
44
+
45
+ directory.path.should == @directory.path
46
+ end
47
+
48
+ it 'can get its feature file' do
49
+ feature_file = @example.get_ancestor(:feature_file)
50
+
51
+ feature_file.path.should == @directory.feature_files.first.path
52
+ end
53
+
54
+ it 'can get its feature' do
55
+ feature = @example.get_ancestor(:feature)
56
+
57
+ feature.name.should == @directory.feature_files.first.features.first.name
58
+ end
59
+
60
+ it 'can get its test' do
61
+ test = @example.get_ancestor(:test)
62
+
63
+ test.name.should == @directory.feature_files.first.features.first.tests.first.name
64
+ end
65
+
66
+ it 'returns nil if it does not have the requested type of ancestor' do
67
+ example = @example.get_ancestor(:example)
68
+
69
+ example.should be_nil
70
+ end
71
+
72
+ end
23
73
  end
@@ -17,4 +17,28 @@ describe 'FeatureFile, Integration' do
17
17
  feature.parent_element.should equal file
18
18
  end
19
19
 
20
+ context 'getting stuff' do
21
+
22
+ before(:each) do
23
+ file_path = "#{@default_file_directory}/feature_file_test_file.feature"
24
+ File.open(file_path, 'w') { |file| file.write('Feature: Test feature') }
25
+
26
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
27
+ @feature_file = @directory.feature_files.first
28
+ end
29
+
30
+
31
+ it 'can get its directory' do
32
+ directory = @feature_file.get_ancestor(:directory)
33
+
34
+ directory.path.should == @directory.path
35
+ end
36
+
37
+ it 'returns nil if it does not have the requested type of ancestor' do
38
+ example = @feature_file.get_ancestor(:example)
39
+
40
+ example.should be_nil
41
+ end
42
+
43
+ end
20
44
  end
@@ -86,4 +86,38 @@ describe 'Feature, Integration' do
86
86
  feature_2.test_case_count.should == 3
87
87
  end
88
88
 
89
+
90
+ context 'getting stuff' do
91
+
92
+ before(:each) do
93
+ source = ['Feature: Test feature']
94
+ source = source.join("\n")
95
+
96
+ file_path = "#{@default_file_directory}/feature_test_file.feature"
97
+ File.open(file_path, 'w') { |file| file.write(source) }
98
+
99
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
100
+ @feature = @directory.feature_files.first.features.first
101
+ end
102
+
103
+
104
+ it 'can get its directory' do
105
+ directory = @feature.get_ancestor(:directory)
106
+
107
+ directory.path.should == @directory.path
108
+ end
109
+
110
+ it 'can get its feature file' do
111
+ feature_file = @feature.get_ancestor(:feature_file)
112
+
113
+ feature_file.path.should == @directory.feature_files.first.path
114
+ end
115
+
116
+ it 'returns nil if it does not have the requested type of ancestor' do
117
+ test = @feature.get_ancestor(:test)
118
+
119
+ test.should be_nil
120
+ end
121
+
122
+ end
89
123
  end
@@ -22,4 +22,49 @@ describe 'Outline, Integration' do
22
22
  tag.parent_element.should equal outline
23
23
  end
24
24
 
25
+
26
+ context 'getting stuff' do
27
+
28
+ before(:each) do
29
+ source = ['Feature: Test feature',
30
+ '',
31
+ ' Scenario Outline: Test test',
32
+ ' * a step',
33
+ ' Examples: Test example',
34
+ ' | a param |']
35
+ source = source.join("\n")
36
+
37
+ file_path = "#{@default_file_directory}/outline_test_file.feature"
38
+ File.open(file_path, 'w') { |file| file.write(source) }
39
+
40
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
41
+ @outline = @directory.feature_files.first.features.first.tests.first
42
+ end
43
+
44
+
45
+ it 'can get its directory' do
46
+ directory = @outline.get_ancestor(:directory)
47
+
48
+ directory.path.should == @directory.path
49
+ end
50
+
51
+ it 'can get its feature file' do
52
+ feature_file = @outline.get_ancestor(:feature_file)
53
+
54
+ feature_file.path.should == @directory.feature_files.first.path
55
+ end
56
+
57
+ it 'can get its feature' do
58
+ feature = @outline.get_ancestor(:feature)
59
+
60
+ feature.name.should == @directory.feature_files.first.features.first.name
61
+ end
62
+
63
+ it 'returns nil if it does not have the requested type of ancestor' do
64
+ test = @outline.get_ancestor(:test)
65
+
66
+ test.should be_nil
67
+ end
68
+
69
+ end
25
70
  end
@@ -18,4 +18,47 @@ describe 'Scenario, Integration' do
18
18
  tag.parent_element.should equal scenario
19
19
  end
20
20
 
21
+
22
+ context 'getting stuff' do
23
+
24
+ before(:each) do
25
+ source = ['Feature: Test feature',
26
+ '',
27
+ ' Scenario: Test test',
28
+ ' * a step']
29
+ source = source.join("\n")
30
+
31
+ file_path = "#{@default_file_directory}/scenario_test_file.feature"
32
+ File.open(file_path, 'w') { |file| file.write(source) }
33
+
34
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
35
+ @scenario = @directory.feature_files.first.features.first.tests.first
36
+ end
37
+
38
+
39
+ it 'can get its directory' do
40
+ directory = @scenario.get_ancestor(:directory)
41
+
42
+ directory.path.should == @directory.path
43
+ end
44
+
45
+ it 'can get its feature file' do
46
+ feature_file = @scenario.get_ancestor(:feature_file)
47
+
48
+ feature_file.path.should == @directory.feature_files.first.path
49
+ end
50
+
51
+ it 'can get its feature' do
52
+ feature = @scenario.get_ancestor(:feature)
53
+
54
+ feature.name.should == @directory.feature_files.first.features.first.name
55
+ end
56
+
57
+ it 'returns nil if it does not have the requested type of ancestor' do
58
+ test = @scenario.get_ancestor(:test)
59
+
60
+ test.should be_nil
61
+ end
62
+
63
+ end
21
64
  end
@@ -62,55 +62,103 @@ describe 'Step, Integration' do
62
62
  end
63
63
 
64
64
  it 'can determine its equality with another Step' do
65
- source_1 = "Given a test step with *parameter 1* and *parameter 2*\n|a block|"
66
- source_2 = "Given a test step with *parameter 3* and *parameter 4*\n|another block|"
67
- source_3 = 'Given a different *parameterized* step'
65
+ source_1 = "Given a test step with *parameter 1* and *parameter 2*\n|a block|"
66
+ source_2 = "Given a test step with *parameter 3* and *parameter 4*\n|another block|"
67
+ source_3 = 'Given a different *parameterized* step'
68
68
 
69
- step_1 = CucumberAnalytics::Step.new(source_1)
70
- step_2 = CucumberAnalytics::Step.new(source_2)
71
- step_3 = CucumberAnalytics::Step.new(source_3)
69
+ step_1 = CucumberAnalytics::Step.new(source_1)
70
+ step_2 = CucumberAnalytics::Step.new(source_2)
71
+ step_3 = CucumberAnalytics::Step.new(source_3)
72
72
 
73
- step_1.delimiter = '*'
74
- step_2.delimiter = '*'
75
- step_3.delimiter = '*'
73
+ step_1.delimiter = '*'
74
+ step_2.delimiter = '*'
75
+ step_3.delimiter = '*'
76
76
 
77
77
 
78
- (step_1 == step_2).should be_true
79
- (step_1 == step_3).should be_false
78
+ (step_1 == step_2).should be_true
79
+ (step_1 == step_3).should be_false
80
80
  end
81
81
 
82
82
  context '#step_text ' do
83
83
 
84
- before(:each) do
85
- source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
86
- @step = CucumberAnalytics::Step.new(source)
87
- end
84
+ before(:each) do
85
+ source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
86
+ @step = CucumberAnalytics::Step.new(source)
87
+ end
88
88
 
89
89
 
90
- it 'returns the step\'s entire text by default' do
91
- source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
92
- step_with_block = CucumberAnalytics::Step.new(source)
90
+ it 'returns the step\'s entire text by default' do
91
+ source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
92
+ step_with_block = CucumberAnalytics::Step.new(source)
93
93
 
94
- expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!',
95
- '|a block|']
94
+ expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!',
95
+ '|a block|']
96
96
 
97
- step_with_block.step_text.should == expected_output
97
+ step_with_block.step_text.should == expected_output
98
98
 
99
- source = 'Given a test step with -parameter 1- ^and@ *parameter 2!!'
100
- step_without_block = CucumberAnalytics::Step.new(source)
99
+ source = 'Given a test step with -parameter 1- ^and@ *parameter 2!!'
100
+ step_without_block = CucumberAnalytics::Step.new(source)
101
101
 
102
- expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!']
102
+ expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!']
103
103
 
104
- step_without_block.step_text.should == expected_output
105
- end
104
+ step_without_block.step_text.should == expected_output
105
+ end
106
106
 
107
- it 'can provide the step\'s text without the keyword' do
108
- expected_output = ['a test step with -parameter 1- ^and@ *parameter 2!!',
109
- '|a block|']
107
+ it 'can provide the step\'s text without the keyword' do
108
+ expected_output = ['a test step with -parameter 1- ^and@ *parameter 2!!',
109
+ '|a block|']
110
110
 
111
- @step.step_text(with_keywords: false).should == expected_output
112
- end
111
+ @step.step_text(with_keywords: false).should == expected_output
112
+ end
113
113
 
114
114
  end
115
115
 
116
+ context 'getting stuff' do
117
+
118
+ before(:each) do
119
+ source = ['Feature: Test feature',
120
+ '',
121
+ ' Scenario: Test test',
122
+ ' * a step:']
123
+ source = source.join("\n")
124
+
125
+ file_path = "#{@default_file_directory}/step_test_file.feature"
126
+ File.open(file_path, 'w') { |file| file.write(source) }
127
+
128
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
129
+ @step = @directory.feature_files.first.features.first.tests.first.steps.first
130
+ end
131
+
132
+
133
+ it 'can get its directory' do
134
+ directory = @step.get_ancestor(:directory)
135
+
136
+ directory.path.should == @directory.path
137
+ end
138
+
139
+ it 'can get its feature file' do
140
+ feature_file = @step.get_ancestor(:feature_file)
141
+
142
+ feature_file.path.should == @directory.feature_files.first.path
143
+ end
144
+
145
+ it 'can get its feature' do
146
+ feature = @step.get_ancestor(:feature)
147
+
148
+ feature.name.should == @directory.feature_files.first.features.first.name
149
+ end
150
+
151
+ it 'can get its test' do
152
+ test = @step.get_ancestor(:test)
153
+
154
+ test.name.should == @directory.feature_files.first.features.first.tests.first.name
155
+ end
156
+
157
+ it 'returns nil if it does not have the requested type of ancestor' do
158
+ example = @step.get_ancestor(:example)
159
+
160
+ example.should be_nil
161
+ end
162
+
163
+ end
116
164
  end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Tag') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Tag, Integration' do
6
+
7
+ context 'getting stuff' do
8
+
9
+ before(:each) do
10
+ source = ['@feature_tag',
11
+ 'Feature: Test feature',
12
+ '',
13
+ ' Scenario Outline: Test test',
14
+ ' * a step',
15
+ '',
16
+ ' @example_tag',
17
+ ' Examples: Test example',
18
+ ' | a param |']
19
+ source = source.join("\n")
20
+
21
+ file_path = "#{@default_file_directory}/tag_test_file.feature"
22
+ File.open(file_path, 'w') { |file| file.write(source) }
23
+
24
+ @directory = CucumberAnalytics::Directory.new(@default_file_directory)
25
+ @tag = @directory.feature_files.first.features.first.tests.first.examples.first.tag_elements.first
26
+ @high_level_tag = @directory.feature_files.first.features.first.tag_elements.first
27
+ end
28
+
29
+
30
+ it 'can get its directory' do
31
+ directory = @tag.get_ancestor(:directory)
32
+
33
+ directory.path.should == @directory.path
34
+ end
35
+
36
+ it 'can get its feature file' do
37
+ feature_file = @tag.get_ancestor(:feature_file)
38
+
39
+ feature_file.path.should == @directory.feature_files.first.path
40
+ end
41
+
42
+ it 'can get its feature' do
43
+ feature = @tag.get_ancestor(:feature)
44
+
45
+ feature.name.should == @directory.feature_files.first.features.first.name
46
+ end
47
+
48
+ it 'can get its test' do
49
+ test = @tag.get_ancestor(:test)
50
+
51
+ test.name.should == @directory.feature_files.first.features.first.tests.first.name
52
+ end
53
+
54
+ it 'can get its example' do
55
+ example = @tag.get_ancestor(:example)
56
+
57
+ example.name.should == @directory.feature_files.first.features.first.tests.first.examples.first.name
58
+ end
59
+
60
+ it 'returns nil if it does not have the requested type of ancestor' do
61
+ example = @high_level_tag.get_ancestor(:example)
62
+
63
+ example.should be_nil
64
+ end
65
+
66
+ end
67
+ end
@@ -16,9 +16,12 @@ describe 'Background, Unit' do
16
16
  it_should_behave_like 'a raw element', clazz
17
17
 
18
18
  it 'can be parsed from stand alone text' do
19
- source = 'Background: '
19
+ source = 'Background: test background'
20
20
 
21
- expect { clazz.new(source) }.to_not raise_error
21
+ expect { @element = clazz.new(source) }.to_not raise_error
22
+
23
+ # Sanity check in case instantiation failed in a non-explosive manner
24
+ @element.name.should == 'test background'
22
25
  end
23
26
 
24
27
  end
@@ -14,7 +14,10 @@ describe 'DocString, Unit' do
14
14
  it 'can be parsed from stand alone text' do
15
15
  source = "\"\"\"\nsome doc string\n\"\"\""
16
16
 
17
- expect { clazz.new(source) }.to_not raise_error
17
+ expect { @element = clazz.new(source) }.to_not raise_error
18
+
19
+ # Sanity check in case instantiation failed in a non-explosive manner
20
+ @element.contents.should == ["some doc string"]
18
21
  end
19
22
 
20
23
  before(:each) do
@@ -17,12 +17,15 @@ describe 'Example, Unit' do
17
17
 
18
18
 
19
19
  it 'can be parsed from stand alone text' do
20
- source = ['Examples: ',
20
+ source = ['Examples: test example',
21
21
  '|param| ']
22
22
 
23
23
  source = source.join("\n")
24
24
 
25
- expect { clazz.new(source) }.to_not raise_error
25
+ expect { @element = clazz.new(source) }.to_not raise_error
26
+
27
+ # Sanity check in case instantiation failed in a non-explosive manner
28
+ @element.name.should == 'test example'
26
29
  end
27
30
 
28
31
 
@@ -20,9 +20,12 @@ describe 'Feature, Unit' do
20
20
  end
21
21
 
22
22
  it 'can be parsed from stand alone text' do
23
- source = 'Feature: '
23
+ source = 'Feature: test feature'
24
24
 
25
- expect { clazz.new(source) }.to_not raise_error
25
+ expect { @element = clazz.new(source) }.to_not raise_error
26
+
27
+ # Sanity check in case instantiation failed in a non-explosive manner
28
+ @element.name.should == 'test feature'
26
29
  end
27
30
 
28
31
  it 'has a background - #background' do
@@ -10,15 +10,27 @@ shared_examples_for 'a nested element' do |clazz|
10
10
  @nested_element.should respond_to(:parent_element)
11
11
  end
12
12
 
13
- it 'can get and set its parent element - #parent_element, #parent_element=' do
14
- @nested_element.parent_element = :some_parent_element
15
- @nested_element.parent_element.should == :some_parent_element
16
- @nested_element.parent_element = :some_other_parent_element
17
- @nested_element.parent_element.should == :some_other_parent_element
18
- end
13
+ it 'can get and set its parent element - #parent_element, #parent_element=' do
14
+ @nested_element.parent_element = :some_parent_element
15
+ @nested_element.parent_element.should == :some_parent_element
16
+ @nested_element.parent_element = :some_other_parent_element
17
+ @nested_element.parent_element.should == :some_other_parent_element
18
+ end
19
19
 
20
20
  it 'starts with no parent element' do
21
21
  @nested_element.parent_element.should == nil
22
22
  end
23
23
 
24
+ it 'has access to its ancestors' do
25
+ @nested_element.should respond_to(:get_ancestor)
26
+ end
27
+
28
+ it 'gets an ancestor based on type' do
29
+ (clazz.instance_method(:get_ancestor).arity == 1).should be_true
30
+ end
31
+
32
+ it 'raises and exception if an unknown ancestor type is requested' do
33
+ expect { @nested_element.get_ancestor(:bad_ancestor_type) }.to raise_exception(ArgumentError)
34
+ end
35
+
24
36
  end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Nested') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Nested, Unit' do
6
+
7
+ nodule = CucumberAnalytics::Nested
8
+
9
+ before(:each) do
10
+ @nested_element = Object.new.extend(nodule)
11
+ end
12
+
13
+
14
+ it 'has a parent element - #parent_element' do
15
+ @nested_element.should respond_to(:parent_element)
16
+ end
17
+
18
+ it 'can get and set its parent element - #parent_element, #parent_element=' do
19
+ @nested_element.parent_element = :some_parent_element
20
+ @nested_element.parent_element.should == :some_parent_element
21
+ @nested_element.parent_element = :some_other_parent_element
22
+ @nested_element.parent_element.should == :some_other_parent_element
23
+ end
24
+
25
+ it 'has access to its ancestors' do
26
+ @nested_element.should respond_to(:get_ancestor)
27
+ end
28
+
29
+ it 'gets an ancestor based on type' do
30
+ (nodule.instance_method(:get_ancestor).arity == 1).should be_true
31
+ end
32
+
33
+ it 'raises and exception if an unknown ancestor type is requested' do
34
+ expect { @nested_element.get_ancestor(:bad_ancestor_type) }.to raise_exception(ArgumentError)
35
+ end
36
+
37
+ end
@@ -18,9 +18,12 @@ describe 'Outline, Unit' do
18
18
 
19
19
 
20
20
  it 'can be parsed from stand alone text' do
21
- source = 'Scenario Outline: '
21
+ source = 'Scenario Outline: test outline'
22
22
 
23
- expect { clazz.new(source) }.to_not raise_error
23
+ expect { @element = clazz.new(source) }.to_not raise_error
24
+
25
+ # Sanity check in case instantiation failed in a non-explosive manner
26
+ @element.name.should == 'test outline'
24
27
  end
25
28
 
26
29
 
@@ -15,7 +15,10 @@ describe 'Row, Unit' do
15
15
  it 'can be parsed from stand alone text' do
16
16
  source = '| a | row |'
17
17
 
18
- expect { clazz.new(source) }.to_not raise_error
18
+ expect { @element = clazz.new(source) }.to_not raise_error
19
+
20
+ # Sanity check in case instantiation failed in a non-explosive manner
21
+ @element.cells.should == ['a', 'row']
19
22
  end
20
23
 
21
24
  before(:each) do
@@ -17,9 +17,12 @@ describe 'Scenario, Unit' do
17
17
  it_should_behave_like 'a raw element', clazz
18
18
 
19
19
  it 'can be parsed from stand alone text' do
20
- source = 'Scenario: '
20
+ source = 'Scenario: test scenario'
21
21
 
22
- expect { clazz.new(source) }.to_not raise_error
22
+ expect { @element = clazz.new(source) }.to_not raise_error
23
+
24
+ # Sanity check in case instantiation failed in a non-explosive manner
25
+ @element.name.should == 'test scenario'
23
26
  end
24
27
 
25
28
  before(:each) do
@@ -179,9 +179,12 @@ describe 'Step, Unit' do
179
179
  end
180
180
 
181
181
  it 'can be parsed from stand alone text' do
182
- source = '* some step'
182
+ source = '* test step'
183
183
 
184
- expect { clazz.new(source) }.to_not raise_error
184
+ expect { @element = clazz.new(source) }.to_not raise_error
185
+
186
+ # Sanity check in case instantiation failed in a non-explosive manner
187
+ @element.base.should == 'test step'
185
188
  end
186
189
 
187
190
  context '#step_text ' do
@@ -14,7 +14,10 @@ describe 'Table, Unit' do
14
14
  it 'can be parsed from stand alone text' do
15
15
  source = '| a table |'
16
16
 
17
- expect { clazz.new(source) }.to_not raise_error
17
+ expect { @element = clazz.new(source) }.to_not raise_error
18
+
19
+ # Sanity check in case instantiation failed in a non-explosive manner
20
+ @element.contents.should == [['a table']]
18
21
  end
19
22
 
20
23
  before(:each) do
@@ -67,7 +67,7 @@ describe 'World, Unit' do
67
67
  end
68
68
 
69
69
  it 'can load step definition files - #load_step_file' do
70
- file_path = "#{DEFAULT_FILE_DIRECTORY}/step_file.rb"
70
+ file_path = "#{@default_file_directory}/step_file.rb"
71
71
  patterns = [/a pattern/, /another pattern/]
72
72
 
73
73
  File.open(file_path, 'w') { |file|
@@ -75,13 +75,14 @@ describe 'World, Unit' do
75
75
  file.puts "Given #{pattern.inspect} do end"
76
76
  end
77
77
  }
78
+
78
79
  @world.load_step_file(file_path)
79
80
 
80
81
  @world.loaded_step_patterns.should =~ patterns
81
82
  end
82
83
 
83
84
  it 'can handle different step keywords - #load_step_file' do
84
- file_path = "#{DEFAULT_FILE_DIRECTORY}/step_file.rb"
85
+ file_path = "#{@default_file_directory}/step_file.rb"
85
86
  patterns = [/given pattern/, /when pattern/, /then pattern/, /and pattern/, /but pattern/]
86
87
 
87
88
  File.open(file_path, 'w') { |file|
@@ -98,7 +99,7 @@ describe 'World, Unit' do
98
99
  end
99
100
 
100
101
  it 'can handle a variety of declaration structures - #load_step_file' do
101
- file_path = "#{DEFAULT_FILE_DIRECTORY}/step_file.rb"
102
+ file_path = "#{@default_file_directory}/step_file.rb"
102
103
  patterns = [/parentheses pattern/, /no parentheses pattern/, /excess whitespace pattern/]
103
104
 
104
105
  File.open(file_path, 'w') { |file|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-02 00:00:00.000000000 Z
11
+ date: 2013-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gherkin
@@ -139,6 +139,7 @@ files:
139
139
  - lib/cucumber_analytics/feature.rb
140
140
  - lib/cucumber_analytics/feature_element.rb
141
141
  - lib/cucumber_analytics/feature_file.rb
142
+ - lib/cucumber_analytics/nested.rb
142
143
  - lib/cucumber_analytics/outline.rb
143
144
  - lib/cucumber_analytics/parsing.rb
144
145
  - lib/cucumber_analytics/raw.rb
@@ -154,12 +155,14 @@ files:
154
155
  - lib/cucumber_analytics/world.rb
155
156
  - spec/integration/background_integration_spec.rb
156
157
  - spec/integration/directory_integration_spec.rb
158
+ - spec/integration/doc_string_integration_spec.rb
157
159
  - spec/integration/example_integration_spec.rb
158
160
  - spec/integration/feature_file_integration_spec.rb
159
161
  - spec/integration/feature_integration_spec.rb
160
162
  - spec/integration/outline_integration_spec.rb
161
163
  - spec/integration/scenario_integration_spec.rb
162
164
  - spec/integration/step_integration_spec.rb
165
+ - spec/integration/tag_integration_spec.rb
163
166
  - spec/integration/world_integration_spec.rb
164
167
  - spec/spec_helper.rb
165
168
  - spec/unit/background_unit_spec.rb
@@ -173,6 +176,7 @@ files:
173
176
  - spec/unit/feature_file_unit_spec.rb
174
177
  - spec/unit/feature_unit_spec.rb
175
178
  - spec/unit/nested_element_unit_specs.rb
179
+ - spec/unit/nested_unit_spec.rb
176
180
  - spec/unit/outline_unit_spec.rb
177
181
  - spec/unit/parsing_unit_spec.rb
178
182
  - spec/unit/prepopulated_unit_specs.rb
@@ -191,7 +195,8 @@ files:
191
195
  - spec/unit/test_element_unit_specs.rb
192
196
  - spec/unit/world_unit_spec.rb
193
197
  homepage: https://github.com/enkessler/cucumber_analytics
194
- licenses: []
198
+ licenses:
199
+ - MIT
195
200
  metadata: {}
196
201
  post_install_message:
197
202
  rdoc_options: []
@@ -252,12 +257,14 @@ test_files:
252
257
  - features/support/transforms.rb
253
258
  - spec/integration/background_integration_spec.rb
254
259
  - spec/integration/directory_integration_spec.rb
260
+ - spec/integration/doc_string_integration_spec.rb
255
261
  - spec/integration/example_integration_spec.rb
256
262
  - spec/integration/feature_file_integration_spec.rb
257
263
  - spec/integration/feature_integration_spec.rb
258
264
  - spec/integration/outline_integration_spec.rb
259
265
  - spec/integration/scenario_integration_spec.rb
260
266
  - spec/integration/step_integration_spec.rb
267
+ - spec/integration/tag_integration_spec.rb
261
268
  - spec/integration/world_integration_spec.rb
262
269
  - spec/spec_helper.rb
263
270
  - spec/unit/background_unit_spec.rb
@@ -271,6 +278,7 @@ test_files:
271
278
  - spec/unit/feature_file_unit_spec.rb
272
279
  - spec/unit/feature_unit_spec.rb
273
280
  - spec/unit/nested_element_unit_specs.rb
281
+ - spec/unit/nested_unit_spec.rb
274
282
  - spec/unit/outline_unit_spec.rb
275
283
  - spec/unit/parsing_unit_spec.rb
276
284
  - spec/unit/prepopulated_unit_specs.rb