cucumber_analytics 1.1.1 → 1.2.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 (64) hide show
  1. checksums.yaml +8 -8
  2. data/.simplecov +5 -1
  3. data/History.rdoc +16 -5
  4. data/README.rdoc +5 -0
  5. data/Rakefile +6 -1
  6. data/features/modeling/background_modeling.feature +5 -1
  7. data/features/modeling/directory_modeling.feature +1 -1
  8. data/features/modeling/doc_string_modeling.feature +5 -1
  9. data/features/modeling/example_modeling.feature +5 -1
  10. data/features/modeling/feature_file_modeling.feature +1 -1
  11. data/features/modeling/feature_modeling.feature +15 -10
  12. data/features/modeling/outline_modeling.feature +6 -1
  13. data/features/modeling/row_modeling.feature +5 -1
  14. data/features/modeling/scenario_modeling.feature +6 -1
  15. data/features/modeling/step_modeling.feature +6 -1
  16. data/features/modeling/table_modeling.feature +5 -1
  17. data/features/modeling/tag_modeling.feature +51 -0
  18. data/features/step_definitions/background_steps.rb +12 -0
  19. data/features/step_definitions/doc_string_steps.rb +10 -0
  20. data/features/step_definitions/feature_steps.rb +14 -5
  21. data/features/step_definitions/outline_steps.rb +31 -15
  22. data/features/step_definitions/spec_steps.rb +1 -1
  23. data/features/step_definitions/step_steps.rb +10 -0
  24. data/features/step_definitions/table_steps.rb +11 -0
  25. data/features/step_definitions/tag_steps.rb +53 -0
  26. data/features/step_definitions/test_steps.rb +20 -8
  27. data/features/step_definitions/world_steps.rb +16 -12
  28. data/lib/cucumber_analytics/background.rb +10 -0
  29. data/lib/cucumber_analytics/doc_string.rb +12 -0
  30. data/lib/cucumber_analytics/example.rb +1 -0
  31. data/lib/cucumber_analytics/feature.rb +2 -1
  32. data/lib/cucumber_analytics/feature_element.rb +2 -0
  33. data/lib/cucumber_analytics/outline.rb +1 -0
  34. data/lib/cucumber_analytics/raw.rb +20 -0
  35. data/lib/cucumber_analytics/row.rb +3 -0
  36. data/lib/cucumber_analytics/scenario.rb +1 -0
  37. data/lib/cucumber_analytics/step.rb +3 -0
  38. data/lib/cucumber_analytics/table.rb +8 -0
  39. data/lib/cucumber_analytics/tag.rb +59 -0
  40. data/lib/cucumber_analytics/taggable.rb +15 -0
  41. data/lib/cucumber_analytics/version.rb +1 -1
  42. data/lib/cucumber_analytics/world.rb +5 -0
  43. data/lib/cucumber_analytics.rb +2 -0
  44. data/spec/integration/example_integration_spec.rb +4 -1
  45. data/spec/integration/feature_integration_spec.rb +11 -8
  46. data/spec/integration/outline_integration_spec.rb +4 -1
  47. data/spec/integration/scenario_integration_spec.rb +4 -1
  48. data/spec/spec_helper.rb +1 -0
  49. data/spec/unit/background_unit_spec.rb +1 -0
  50. data/spec/unit/doc_string_unit_spec.rb +1 -0
  51. data/spec/unit/example_unit_spec.rb +1 -0
  52. data/spec/unit/feature_unit_spec.rb +12 -0
  53. data/spec/unit/outline_unit_spec.rb +1 -0
  54. data/spec/unit/raw_element_unit_specs.rb +24 -0
  55. data/spec/unit/raw_unit_spec.rb +25 -0
  56. data/spec/unit/row_unit_spec.rb +1 -0
  57. data/spec/unit/scenario_unit_spec.rb +1 -0
  58. data/spec/unit/step_unit_spec.rb +1 -0
  59. data/spec/unit/table_unit_spec.rb +1 -0
  60. data/spec/unit/tag_unit_spec.rb +39 -0
  61. data/spec/unit/taggable_unit_spec.rb +22 -7
  62. data/spec/unit/tagged_element_unit_specs.rb +22 -7
  63. data/spec/unit/world_unit_spec.rb +3 -2
  64. metadata +14 -2
@@ -5,6 +5,8 @@ module CucumberAnalytics
5
5
  class Row
6
6
 
7
7
  include Sourceable
8
+ include Raw
9
+
8
10
 
9
11
  # The parent object that contains *self*
10
12
  attr_accessor :parent_element
@@ -48,6 +50,7 @@ module CucumberAnalytics
48
50
  def build_row(parsed_row)
49
51
  populate_element_source_line(parsed_row)
50
52
  populate_row_cells(parsed_row)
53
+ populate_raw_element(parsed_row)
51
54
  end
52
55
 
53
56
  def populate_row_cells(parsed_row)
@@ -15,6 +15,7 @@ module CucumberAnalytics
15
15
  super(parsed_scenario)
16
16
 
17
17
  @tags = []
18
+ @tag_elements = []
18
19
 
19
20
  build_scenario(parsed_scenario) if parsed_scenario
20
21
  end
@@ -6,6 +6,8 @@ module CucumberAnalytics
6
6
 
7
7
  include Containing
8
8
  include Sourceable
9
+ include Raw
10
+
9
11
 
10
12
  # The step's keyword
11
13
  attr_accessor :keyword
@@ -158,6 +160,7 @@ module CucumberAnalytics
158
160
  populate_block(step)
159
161
  populate_keyword(step)
160
162
  populate_element_source_line(step)
163
+ populate_raw_element(step)
161
164
 
162
165
  scan_arguments
163
166
  end
@@ -4,6 +4,9 @@ module CucumberAnalytics
4
4
 
5
5
  class Table
6
6
 
7
+ include Raw
8
+
9
+
7
10
  # The parent object that contains *self*
8
11
  attr_accessor :parent_element
9
12
 
@@ -44,6 +47,11 @@ module CucumberAnalytics
44
47
  end
45
48
 
46
49
  def build_table(table)
50
+ populate_contents(table)
51
+ populate_raw_element(table)
52
+ end
53
+
54
+ def populate_contents(table)
47
55
  @contents = table.collect { |row| row['cells'] }
48
56
  end
49
57
 
@@ -0,0 +1,59 @@
1
+ module CucumberAnalytics
2
+
3
+ # A class modeling a Tag.
4
+
5
+ class Tag
6
+
7
+ include Raw
8
+ include Sourceable
9
+
10
+
11
+ # The parent object that contains *self*
12
+ attr_accessor :parent_element
13
+
14
+ # The name of the Tag
15
+ attr_accessor :name
16
+
17
+
18
+ # Creates a new Tag object and, if *source* is provided, populates the
19
+ # object.
20
+ def initialize(source = nil)
21
+ parsed_tag = process_source(source)
22
+
23
+ build_tag(parsed_tag) if parsed_tag
24
+ end
25
+
26
+
27
+ private
28
+
29
+
30
+ def process_source(source)
31
+ case
32
+ when source.is_a?(String)
33
+ parse_tag(source)
34
+ else
35
+ source
36
+ end
37
+ end
38
+
39
+ def parse_tag(source_text)
40
+ base_file_string = "\nFeature: Fake feature to parse"
41
+ source_text = source_text + base_file_string
42
+
43
+ parsed_file = Parsing::parse_text(source_text)
44
+
45
+ parsed_file.first['tags'].first
46
+ end
47
+
48
+ def build_tag(parsed_tag)
49
+ populate_name(parsed_tag)
50
+ populate_raw_element(parsed_tag)
51
+ populate_element_source_line(parsed_tag)
52
+ end
53
+
54
+ def populate_name(parsed_tag)
55
+ @name = parsed_tag['name']
56
+ end
57
+
58
+ end
59
+ end
@@ -7,6 +7,9 @@ module CucumberAnalytics
7
7
  # The tags which are directly assigned to the element
8
8
  attr_accessor :tags
9
9
 
10
+ # The tag elements belonging to the element
11
+ attr_accessor :tag_elements
12
+
10
13
 
11
14
  # Returns the tags which are indirectly assigned to the element (i.e. they
12
15
  # have been inherited from a parent element).
@@ -14,11 +17,22 @@ module CucumberAnalytics
14
17
  @parent_element.respond_to?(:all_tags) ? @parent_element.all_tags : []
15
18
  end
16
19
 
20
+ # Returns the tags elements which are indirectly assigned to the element
21
+ # (i.e. they have been inherited from a parent element).
22
+ def applied_tag_elements
23
+ @parent_element.respond_to?(:all_tag_elements) ? @parent_element.all_tag_elements : []
24
+ end
25
+
17
26
  # Returns all of the tags which are applicable to the element.
18
27
  def all_tags
19
28
  applied_tags + @tags
20
29
  end
21
30
 
31
+ # Returns all of the tag elements which are applicable to the element.
32
+ def all_tag_elements
33
+ applied_tag_elements + @tag_elements
34
+ end
35
+
22
36
 
23
37
  private
24
38
 
@@ -27,6 +41,7 @@ module CucumberAnalytics
27
41
  if parsed_element['tags']
28
42
  parsed_element['tags'].each do |tag|
29
43
  @tags << tag['name']
44
+ @tag_elements << build_child_element(Tag, tag)
30
45
  end
31
46
  end
32
47
  end
@@ -1,3 +1,3 @@
1
1
  module CucumberAnalytics
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -85,6 +85,11 @@ module CucumberAnalytics
85
85
  Array.new.tap { |accumulated_tags| collect_all_in(:tags, container, accumulated_tags) }
86
86
  end
87
87
 
88
+ # Returns all tag elements found in the passed container.
89
+ def tag_elements_in(container)
90
+ Array.new.tap { |accumulated_tag_elements| collect_all_in(:tag_elements, container, accumulated_tag_elements) }
91
+ end
92
+
88
93
  # Returns all directories found in the passed container.
89
94
  def directories_in(container)
90
95
  Array.new.tap { |accumulated_directories| collect_all_in(:directories, container, accumulated_directories) }
@@ -2,6 +2,7 @@ require 'cucumber_analytics/version'
2
2
  require 'cucumber_analytics/parsing'
3
3
  require 'cucumber_analytics/containing'
4
4
  require 'cucumber_analytics/taggable'
5
+ require 'cucumber_analytics/raw'
5
6
  require 'cucumber_analytics/sourceable'
6
7
  require 'cucumber_analytics/feature_file'
7
8
  require 'cucumber_analytics/directory'
@@ -17,3 +18,4 @@ require 'cucumber_analytics/doc_string'
17
18
  require 'cucumber_analytics/table'
18
19
  require 'cucumber_analytics/world'
19
20
  require 'cucumber_analytics/row'
21
+ require 'cucumber_analytics/tag'
@@ -5,16 +5,19 @@ SimpleCov.command_name('Example') unless RUBY_VERSION.to_s < '1.9.0'
5
5
  describe 'Example, Integration' do
6
6
 
7
7
  it 'properly sets its child elements' do
8
- source = ['Examples:',
8
+ source = ['@a_tag',
9
+ 'Examples:',
9
10
  ' | param |',
10
11
  ' | value 1 |']
11
12
  source = source.join("\n")
12
13
 
13
14
  example = CucumberAnalytics::Example.new(source)
14
15
  rows = example.row_elements
16
+ tag = example.tag_elements.first
15
17
 
16
18
  rows[0].parent_element.should equal example
17
19
  rows[1].parent_element.should equal example
20
+ tag.parent_element.should equal example
18
21
  end
19
22
 
20
23
  end
@@ -11,7 +11,8 @@ describe 'Feature, Integration' do
11
11
  end
12
12
 
13
13
  it 'properly sets its child elements' do
14
- source = ['Feature: Test feature',
14
+ source = ['@a_tag',
15
+ 'Feature: Test feature',
15
16
  ' Background: Test background',
16
17
  ' Scenario: Test scenario',
17
18
  ' Scenario Outline: Test outline']
@@ -22,11 +23,13 @@ describe 'Feature, Integration' do
22
23
  background = feature.background
23
24
  scenario = feature.tests[0]
24
25
  outline = feature.tests[1]
26
+ tag = feature.tag_elements[0]
25
27
 
26
28
 
27
29
  outline.parent_element.should equal feature
28
30
  scenario.parent_element.should equal feature
29
31
  background.parent_element.should equal feature
32
+ tag.parent_element.should equal feature
30
33
  end
31
34
 
32
35
  it 'can distinguish scenarios from outlines - #scenarios, #outlines' do
@@ -66,13 +69,13 @@ describe 'Feature, Integration' do
66
69
  source_1 = source_1.join("\n")
67
70
 
68
71
  source_2 = ['Feature: Test feature',
69
- ' Scenario: Test scenario',
70
- ' Scenario Outline: Test outline',
71
- ' * a step',
72
- ' Examples: Test examples',
73
- ' |param|',
74
- ' |value_1|',
75
- ' |value_2|']
72
+ ' Scenario: Test scenario',
73
+ ' Scenario Outline: Test outline',
74
+ ' * a step',
75
+ ' Examples: Test examples',
76
+ ' |param|',
77
+ ' |value_1|',
78
+ ' |value_2|']
76
79
  source_2 = source_2.join("\n")
77
80
 
78
81
  feature_1 = CucumberAnalytics::Feature.new(source_1)
@@ -5,7 +5,8 @@ SimpleCov.command_name('Outline') unless RUBY_VERSION.to_s < '1.9.0'
5
5
  describe 'Outline, Integration' do
6
6
 
7
7
  it 'properly sets its child elements' do
8
- source = [' Scenario Outline:',
8
+ source = ['@a_tag',
9
+ ' Scenario Outline:',
9
10
  ' * a step',
10
11
  ' Examples:',
11
12
  ' | param |']
@@ -14,9 +15,11 @@ describe 'Outline, Integration' do
14
15
  outline = CucumberAnalytics::Outline.new(source)
15
16
  example = outline.examples.first
16
17
  step = outline.steps.first
18
+ tag = outline.tag_elements.first
17
19
 
18
20
  example.parent_element.should equal outline
19
21
  step.parent_element.should equal outline
22
+ tag.parent_element.should equal outline
20
23
  end
21
24
 
22
25
  end
@@ -5,14 +5,17 @@ SimpleCov.command_name('Scenario') unless RUBY_VERSION.to_s < '1.9.0'
5
5
  describe 'Scenario, Integration' do
6
6
 
7
7
  it 'properly sets its child elements' do
8
- source = ['Scenario: Test scenario',
8
+ source = ['@a_tag',
9
+ 'Scenario: Test scenario',
9
10
  ' * a step']
10
11
  source = source.join("\n")
11
12
 
12
13
  scenario = CucumberAnalytics::Scenario.new(source)
13
14
  step = scenario.steps.first
15
+ tag = scenario.tag_elements.first
14
16
 
15
17
  step.parent_element.should equal scenario
18
+ tag.parent_element.should equal scenario
16
19
  end
17
20
 
18
21
  end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,7 @@ require "#{File.dirname(__FILE__)}/unit/bare_bones_unit_specs"
10
10
  require "#{File.dirname(__FILE__)}/unit/test_element_unit_specs"
11
11
  require "#{File.dirname(__FILE__)}/unit/prepopulated_unit_specs"
12
12
  require "#{File.dirname(__FILE__)}/unit/sourced_element_unit_specs"
13
+ require "#{File.dirname(__FILE__)}/unit/raw_element_unit_specs"
13
14
 
14
15
 
15
16
  DEFAULT_FEATURE_FILE_NAME = 'test_feature.feature'
@@ -13,6 +13,7 @@ describe 'Background, Unit' do
13
13
  it_should_behave_like 'a prepopulated element', clazz
14
14
  it_should_behave_like 'a test element', clazz
15
15
  it_should_behave_like 'a sourced element', clazz
16
+ it_should_behave_like 'a raw element', clazz
16
17
 
17
18
  it 'can be parsed from stand alone text' do
18
19
  source = 'Background: '
@@ -9,6 +9,7 @@ describe 'DocString, Unit' do
9
9
  it_should_behave_like 'a nested element', clazz
10
10
  it_should_behave_like 'a bare bones element', clazz
11
11
  it_should_behave_like 'a prepopulated element', clazz
12
+ it_should_behave_like 'a raw element', clazz
12
13
 
13
14
  it 'can be parsed from stand alone text' do
14
15
  source = "\"\"\"\nsome doc string\n\"\"\""
@@ -13,6 +13,7 @@ describe 'Example, Unit' do
13
13
  it_should_behave_like 'a prepopulated element', clazz
14
14
  it_should_behave_like 'a sourced element', clazz
15
15
  it_should_behave_like 'a containing element', clazz
16
+ it_should_behave_like 'a raw element', clazz
16
17
 
17
18
 
18
19
  it 'can be parsed from stand alone text' do
@@ -13,6 +13,7 @@ describe 'Feature, Unit' do
13
13
  it_should_behave_like 'a bare bones element', clazz
14
14
  it_should_behave_like 'a prepopulated element', clazz
15
15
  it_should_behave_like 'a sourced element', clazz
16
+ it_should_behave_like 'a raw element', clazz
16
17
 
17
18
  before(:each) do
18
19
  @feature = clazz.new
@@ -71,6 +72,17 @@ describe 'Feature, Unit' do
71
72
  @feature.contains.should =~ everything
72
73
  end
73
74
 
75
+ it 'contains a background only if one is present' do
76
+ tests = [:test_1, :test_2]
77
+ background = nil
78
+ everything = tests
79
+
80
+ @feature.background = background
81
+ @feature.tests = tests
82
+
83
+ @feature.contains.should =~ everything
84
+ end
85
+
74
86
  it 'starts with no background' do
75
87
  @feature.background.should == nil
76
88
  end
@@ -14,6 +14,7 @@ describe 'Outline, Unit' do
14
14
  it_should_behave_like 'a prepopulated element', clazz
15
15
  it_should_behave_like 'a test element', clazz
16
16
  it_should_behave_like 'a sourced element', clazz
17
+ it_should_behave_like 'a raw element', clazz
17
18
 
18
19
 
19
20
  it 'can be parsed from stand alone text' do
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for 'a raw element' do |clazz|
4
+
5
+ before(:each) do
6
+ @element = clazz.new
7
+ end
8
+
9
+ it 'has an underlying implementation representation - #raw_element' do
10
+ @element.should respond_to(:raw_element)
11
+ end
12
+
13
+ it 'can get and set its underlying implementation representation - #raw_element, #raw_element=' do
14
+ @element.raw_element = :some_raw_element
15
+ @element.raw_element.should == :some_raw_element
16
+ @element.raw_element = :some_other_raw_element
17
+ @element.raw_element.should == :some_other_raw_element
18
+ end
19
+
20
+ it 'starts with no underlying implementation representation' do
21
+ @element.raw_element.should == nil
22
+ end
23
+
24
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Raw') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Raw, Unit' do
6
+
7
+ nodule = CucumberAnalytics::Raw
8
+
9
+ before(:each) do
10
+ @element = Object.new.extend(nodule)
11
+ end
12
+
13
+
14
+ it 'has a raw element - #raw_element' do
15
+ @element.should respond_to(:raw_element)
16
+ end
17
+
18
+ it 'can get and set its raw element - #raw_element, #raw_element=' do
19
+ @element.raw_element = :some_raw_element
20
+ @element.raw_element.should == :some_raw_element
21
+ @element.raw_element = :some_other_raw_element
22
+ @element.raw_element.should == :some_other_raw_element
23
+ end
24
+
25
+ end
@@ -10,6 +10,7 @@ describe 'Row, Unit' do
10
10
  it_should_behave_like 'a bare bones element', clazz
11
11
  it_should_behave_like 'a prepopulated element', clazz
12
12
  it_should_behave_like 'a sourced element', clazz
13
+ it_should_behave_like 'a raw element', clazz
13
14
 
14
15
  it 'can be parsed from stand alone text' do
15
16
  source = '| a | row |'
@@ -14,6 +14,7 @@ describe 'Scenario, Unit' do
14
14
  it_should_behave_like 'a prepopulated element', clazz
15
15
  it_should_behave_like 'a test element', clazz
16
16
  it_should_behave_like 'a sourced element', clazz
17
+ it_should_behave_like 'a raw element', clazz
17
18
 
18
19
  it 'can be parsed from stand alone text' do
19
20
  source = 'Scenario: '