cuporter 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -1,6 +1,6 @@
1
1
  h1. Cuporter
2
2
 
3
- Scrapes your feature files and shows scenarios per tag, with their context. Formats Pretty Text, HTML (not styled yet) and CSV.
3
+ Scrapes your feature files and shows scenarios per tag, with their context. Formats Pretty Text, HTML and CSV.
4
4
 
5
5
  Consider this a stop-gap until we get this functionality in a proper cucumber formatter.
6
6
 
@@ -16,11 +16,20 @@ h3. Example Output
16
16
  Scenario: Everybody's Wired
17
17
  Scenario Outline: Why is everybody so wired?
18
18
  Examples: loosely wired
19
+ | arg1 | arg2 |
20
+ | foo | bar |
21
+ | shif | fish |
19
22
  Examples: tightly wired
23
+ | name | value |
24
+ | foo | bar |
25
+ | frotz | knurl |
20
26
  @ignore
21
27
  Feature: Wired
22
28
  Scenario Outline: Why is everybody so wired?
23
29
  Examples: tightly wired
30
+ | name | value |
31
+ | foo | bar |
32
+ | frotz | knurl |
24
33
  @wip
25
34
  Feature: HTML formatter
26
35
  Scenario: Everything in fixtures/self_test
@@ -35,6 +44,14 @@ h3. Example Output
35
44
 
36
45
  ---------
37
46
 
47
+ h3. Install
48
+
49
+ <pre>
50
+ $ gem install cuporter
51
+ </pre>
52
+
53
+ ---------
54
+
38
55
  h3. Command Lines
39
56
 
40
57
  h4. help
data/Rakefile CHANGED
@@ -56,7 +56,7 @@ namespace :cuporter do
56
56
 
57
57
  spec = Gem::Specification.new do |s|
58
58
  s.name = 'cuporter'
59
- s.version = '0.1.0'
59
+ s.version = '0.1.1'
60
60
  s.rubyforge_project = s.name
61
61
 
62
62
  s.platform = Gem::Platform::RUBY
@@ -3,5 +3,5 @@ Feature: Pretty print report on 3 features
3
3
  @just_me
4
4
  Scenario: Everything in fixtures/self_test
5
5
  When I run cuporter --in fixtures/self_test
6
- Then the output should have the same contents as "features/reports/pretty_with_outlines.txt"
6
+ Then the output should have the same contents as "features/reports/pretty_with_outlines_and_examples.txt"
7
7
 
@@ -6,8 +6,9 @@ module Cuporter
6
6
  TAG_LINE = /^\s*(@\w.+)/
7
7
  SCENARIO_LINE = /^\s*(Scenario:[^#]+)$/
8
8
  SCENARIO_OUTLINE_LINE = /^\s*(Scenario Outline:[^#]+)$/
9
- SCENARIOS_LINE = /^\s*(Scenarios:[^#]*)$/
10
- EXAMPLES_LINE = /^\s*(Examples:[^#]*)$/
9
+ SCENARIO_SET_LINE = /^\s*(Scenarios:[^#]*)$/
10
+ EXAMPLE_SET_LINE = /^\s*(Examples:[^#]*)$/
11
+ EXAMPLE_LINE = /^\s*(\|.*\|)\s*$/
11
12
 
12
13
  def initialize
13
14
  @current_tags = []
@@ -20,44 +21,52 @@ module Cuporter
20
21
  def parse(feature_content)
21
22
  lines = feature_content.split(/\n/)
22
23
 
23
- lines.each do |line|
24
+ lines.each_with_index do |line, i|
24
25
  case line
25
26
  when TAG_LINE
26
27
  # may be more than one tag line
27
28
  @current_tags |= $1.strip.split(/\s+/)
28
29
  when FEATURE_LINE
29
- @feature = TagListNode.new($1.strip, @current_tags)
30
+ @feature = TagListNode.new($1, @current_tags)
30
31
  @current_tags = []
31
32
  when SCENARIO_LINE
32
33
  # How do we know when we have read all the lines from a "Scenario Outline:"?
33
34
  # One way is when we encounter a "Scenario:"
34
- if @scenario_outline
35
- @feature.merge(@scenario_outline)
36
- @scenario_outline = nil
37
- end
35
+ close_scenario_outline
38
36
 
39
- @feature.add_to_tag_node(Node.new($1.strip), @current_tags)
37
+ @feature.add_to_tag_nodes(TagListNode.new($1, @current_tags))
40
38
  @current_tags = []
41
39
  when SCENARIO_OUTLINE_LINE
42
40
  # ... another is when we hit a subsequent "Scenario Outline:"
43
- if @scenario_outline
44
- @feature.merge(@scenario_outline)
45
- @scenario_outline = nil
46
- end
41
+ close_scenario_outline
47
42
 
48
- @scenario_outline = TagListNode.new($1.strip, @current_tags)
43
+ @scenario_outline = TagListNode.new($1, @current_tags)
49
44
  @current_tags = []
50
- when EXAMPLES_LINE, SCENARIOS_LINE
51
- @scenario_outline.add_to_tag_node(Node.new($1.strip), @feature.universal_tags | @current_tags)
45
+ when EXAMPLE_SET_LINE, SCENARIO_SET_LINE
46
+ @scenario_outline.add_to_tag_nodes(@example_set) if @example_set
47
+
48
+ @example_set = NonSortingNode.new($1, @feature.tags | @current_tags)
52
49
  @current_tags = []
50
+ when EXAMPLE_LINE
51
+ @example_set.add_child(Node.new($1))
53
52
  end
54
53
  end
55
54
 
56
55
  # EOF is the final way that we know we are finished with a "Scenario Outline"
57
- @feature.merge(@scenario_outline) if @scenario_outline
56
+ close_scenario_outline
58
57
  return @feature
59
58
  end
60
59
 
60
+ def close_scenario_outline
61
+ if @scenario_outline
62
+ if @example_set
63
+ @scenario_outline.add_to_tag_nodes(@example_set) if @example_set
64
+ @example_set = nil
65
+ end
66
+ @feature.merge(@scenario_outline)
67
+ @scenario_outline = nil
68
+ end
69
+ end
61
70
  end
62
71
 
63
72
  end
@@ -7,10 +7,10 @@ module Cuporter
7
7
  module Formatters
8
8
  class Html < Writer
9
9
 
10
- NODE_CLASS = [:tag, :feature, :scenario, :example]
10
+ NODE_CLASS = [:tag, :feature, :scenario, :example_set]
11
11
 
12
12
  def write_nodes
13
- @report.children.sort.each do |tag_node|
13
+ @report.sort.children.each do |tag_node|
14
14
  write_node(tag_node, 0)
15
15
  end
16
16
  builder
@@ -21,15 +21,15 @@ module Cuporter
21
21
  end
22
22
 
23
23
  def write_node(node, indent_level)
24
- builder.li do |list_item|
25
- list_item.span(node.name, :class => NODE_CLASS[indent_level])
24
+ builder.li(:class => NODE_CLASS[indent_level]) do |list_item|
25
+ list_item.span(node.name, :class => "#{NODE_CLASS[indent_level]}_name")
26
26
  if node.has_children?
27
- list_item.ul do |list|
28
- node.children.sort.each do |child|
27
+ list_item.ul(:class => "#{NODE_CLASS[indent_level]}_children") do |list|
28
+ node.sort.children.each do |child|
29
29
  if child.has_children?
30
30
  write_node(child, indent_level + 1)
31
31
  else
32
- list.li(child.name, :class => NODE_CLASS[indent_level + 1])
32
+ list.li(child.name, :class => "#{NODE_CLASS[indent_level + 1]}_name")
33
33
  end
34
34
  end
35
35
  end
@@ -37,6 +37,10 @@ module Cuporter
37
37
  end
38
38
  end
39
39
 
40
+ def inline_style
41
+ File.read("lib/cuporter/formatters/cuporter.css")
42
+ end
43
+
40
44
  def get_binding
41
45
  binding
42
46
  end
@@ -54,10 +58,12 @@ module Cuporter
54
58
  <html xmlns="http://www.w3.org/1999/xhtml">
55
59
  <head>
56
60
  <title>Cucumber Tags</title>
57
- <style type="text/css"></style>
61
+ <style type="text/css">
62
+ <%= inline_style%>
63
+ </style>
58
64
  </head>
59
65
  <body>
60
- <ul>
66
+ <ul class="tag_list">
61
67
  <%= write_nodes%>
62
68
  </ul>
63
69
  </body>
@@ -4,16 +4,16 @@ module Cuporter
4
4
  module TextMethods
5
5
 
6
6
  def write
7
- @report.children.sort.each do |tag_node|
7
+ @report.sort.children.each do |tag_node|
8
8
  write_node(tag_node, 0)
9
9
  end
10
10
  end
11
11
 
12
12
  def write_node(node, tab_stops)
13
13
  @output.puts "#{self.class::TAB * tab_stops}#{node.name}"
14
- node.children.sort.each do |child|
14
+ node.sort.children.each do |child|
15
15
  @output.puts "#{self.class::TAB + (self.class::TAB * tab_stops)}#{child.name}"
16
- child.children.sort.each do |grand_child|
16
+ child.sort.children.each do |grand_child|
17
17
  if grand_child.has_children?
18
18
  write_node(grand_child, tab_stops + 2)
19
19
  else
data/lib/cuporter/node.rb CHANGED
@@ -6,7 +6,7 @@ module Cuporter
6
6
  attr_reader :name, :children
7
7
 
8
8
  def initialize(name)
9
- @name = name
9
+ @name = name.strip
10
10
  @children = []
11
11
  end
12
12
 
@@ -42,6 +42,11 @@ module Cuporter
42
42
  @name_without_title ||= name.split(/:\s+/).last
43
43
  end
44
44
 
45
+ def sort
46
+ children.sort!
47
+ self
48
+ end
49
+
45
50
  # sort on name or substring of name after any ':'
46
51
  def <=>(other)
47
52
  name_without_title <=> other.name_without_title
@@ -0,0 +1,16 @@
1
+ # Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
2
+ module Cuporter
3
+ class NonSortingNode < Node
4
+ attr_reader :tags
5
+
6
+ def initialize(name, tags)
7
+ super(name)
8
+ @tags = tags
9
+ end
10
+
11
+ def sort
12
+ self
13
+ end
14
+
15
+ end
16
+ end
@@ -1,21 +1,21 @@
1
1
  # Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
2
2
  module Cuporter
3
- # a node with a list of tags that apply to all children
3
+ # a node with a list of tags that can be applied to all children
4
4
  class TagListNode < Node
5
5
 
6
- attr_reader :universal_tags
6
+ attr_reader :tags
7
7
 
8
- def initialize(name, universal_tags)
8
+ def initialize(name, tags)
9
9
  super(name)
10
- @universal_tags = universal_tags
10
+ @tags = tags
11
11
  end
12
12
 
13
- def has_universal_tags?
14
- @universal_tags.size > 0
13
+ def has_tags?
14
+ @tags.size > 0
15
15
  end
16
16
 
17
- def add_to_tag_node(node, childs_tags = [])
18
- (universal_tags | childs_tags).each do |tag|
17
+ def add_to_tag_nodes(node)
18
+ (tags | node.tags).each do |tag|
19
19
  tag_node = find_or_create_child(tag)
20
20
  tag_node.add_child(node)
21
21
  end
data/lib/cuporter.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
2
2
  require 'cuporter/node'
3
3
  require 'cuporter/tag_list_node'
4
+ require 'cuporter/non_sorting_node'
4
5
  require 'cuporter/feature_parser'
5
6
  require 'cuporter/extensions/string'
6
7
  require 'cuporter/cli/options'
@@ -2,30 +2,30 @@ require 'spec_helper'
2
2
 
3
3
  module Cuporter
4
4
  describe FeatureParser do
5
- context "#universal_tags" do
5
+ context "#tags" do
6
6
  context "one tag" do
7
7
  it "returns one tag" do
8
8
  feature = FeatureParser.parse("@wip\nFeature: foo")
9
- feature.universal_tags.should == ["@wip"]
9
+ feature.tags.should == ["@wip"]
10
10
  end
11
11
  end
12
12
 
13
13
  context "two tags on one line" do
14
14
  it "returns two tags" do
15
15
  feature = FeatureParser.parse(" \n@smoke @wip\nFeature: foo")
16
- feature.universal_tags.sort.should == %w[@smoke @wip].sort
16
+ feature.tags.sort.should == %w[@smoke @wip].sort
17
17
  end
18
18
  end
19
19
  context "two tags on two lines" do
20
20
  it "returns two tags" do
21
21
  feature = FeatureParser.parse(" \n@smoke\n @wip\nFeature: foo")
22
- feature.universal_tags.sort.should == %w[@smoke @wip].sort
22
+ feature.tags.sort.should == %w[@smoke @wip].sort
23
23
  end
24
24
  end
25
25
  context "no tags" do
26
26
  it "returns no tags" do
27
27
  feature = FeatureParser.parse("\nFeature: foo")
28
- feature.universal_tags.should == []
28
+ feature.tags.should == []
29
29
  end
30
30
  end
31
31
 
@@ -0,0 +1,431 @@
1
+ require 'spec_helper'
2
+
3
+ module Cuporter
4
+
5
+ describe "Tag Reports of Scenario Outlines in Single Features" do
6
+
7
+ context "scenario outline with 2 examples" do
8
+ context "1 example tag" do
9
+ it "returns 1 tag mapped to 1 example" do
10
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag.feature")
11
+ report.should == <<EOF
12
+ @smoke
13
+ Feature: foo
14
+ Scenario Outline: outline
15
+ Scenarios: bang
16
+ |foo|bar|fan|
17
+ | 1 | 2 | 3 |
18
+ | 4 | 5 | 6 |
19
+ EOF
20
+ end
21
+ end
22
+
23
+ context "1 tag per example" do
24
+ it "returns 2 examples mapped to a tag" do
25
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_tag_per_example.feature")
26
+ report.should == <<EOF
27
+ @smoke
28
+ Feature: foo
29
+ Scenario Outline: some
30
+ Scenarios: yet
31
+ |foo|bar|fan|
32
+ | 1 | 2 | 3 |
33
+ | 4 | 5 | 6 |
34
+ @wip
35
+ Feature: foo
36
+ Scenario Outline: some
37
+ Scenarios: another
38
+ |foo|bar|fan|
39
+ | 7 | 8 | 9 |
40
+ | 0 | 1 | 2 |
41
+ EOF
42
+ end
43
+ end
44
+
45
+ context "1 tag per example, 2 feature tags" do
46
+ it "returns 4 tags . . ." do
47
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_tag_per_example_2_feature_tags.feature")
48
+ report.should == <<EOF
49
+ @smoke
50
+ Feature: foo
51
+ Scenario Outline: outline
52
+ Scenarios: yet
53
+ |foo|bar|fan|
54
+ | 1 | 2 | 3 |
55
+ | 4 | 5 | 6 |
56
+ @taggy
57
+ Feature: foo
58
+ Scenario Outline: outline
59
+ Scenarios: another
60
+ |foo|bar|fan|
61
+ | 1 | 2 | 3 |
62
+ | 4 | 5 | 6 |
63
+ Scenarios: yet
64
+ |foo|bar|fan|
65
+ | 1 | 2 | 3 |
66
+ | 4 | 5 | 6 |
67
+ @waggy
68
+ Feature: foo
69
+ Scenario Outline: outline
70
+ Scenarios: another
71
+ |foo|bar|fan|
72
+ | 1 | 2 | 3 |
73
+ | 4 | 5 | 6 |
74
+ Scenarios: yet
75
+ |foo|bar|fan|
76
+ | 1 | 2 | 3 |
77
+ | 4 | 5 | 6 |
78
+ @wip
79
+ Feature: foo
80
+ Scenario Outline: outline
81
+ Scenarios: another
82
+ |foo|bar|fan|
83
+ | 1 | 2 | 3 |
84
+ | 4 | 5 | 6 |
85
+ EOF
86
+ end
87
+ end
88
+
89
+ context "1 example tag and 1 feature tag" do
90
+ it "returns 2 tags" do
91
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_and_1_feature_tag.feature")
92
+ report.should == <<EOF
93
+ @f_tag
94
+ Feature: foo
95
+ Scenario Outline: outline
96
+ Scenarios: another
97
+ |foo|bar|fan|
98
+ | 1 | 2 | 3 |
99
+ | 4 | 5 | 6 |
100
+ Scenarios: yet
101
+ |foo|bar|fan|
102
+ | 1 | 2 | 3 |
103
+ | 4 | 5 | 6 |
104
+ @smoke
105
+ Feature: foo
106
+ Scenario Outline: outline
107
+ Scenarios: yet
108
+ |foo|bar|fan|
109
+ | 1 | 2 | 3 |
110
+ | 4 | 5 | 6 |
111
+ EOF
112
+ end
113
+ end
114
+
115
+ context "1 example tag and 1 scenario outline tag" do
116
+ it "returns 1 example mapped to 1 tag" do
117
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_and_1_scenario_outline_tag.feature")
118
+ report.should == <<EOF
119
+ @s_o_tag
120
+ Feature: foo
121
+ Scenario Outline: outline
122
+ Scenarios: another
123
+ |foo|bar|fan|
124
+ | 1 | 2 | 3 |
125
+ | 4 | 5 | 6 |
126
+ Scenarios: yet
127
+ |foo|bar|fan|
128
+ | 1 | 2 | 3 |
129
+ | 4 | 5 | 6 |
130
+ @smoke
131
+ Feature: foo
132
+ Scenario Outline: outline
133
+ Scenarios: yet
134
+ |foo|bar|fan|
135
+ | 1 | 2 | 3 |
136
+ | 4 | 5 | 6 |
137
+ EOF
138
+ end
139
+ end
140
+ context "1 example tag, 1 scenario outline tag, 1 feature tag" do
141
+ it "3 tags" do
142
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_1_scenario_outline_tag_1_feature_tag.feature")
143
+ report.should == <<EOF
144
+ @f_tag
145
+ Feature: foo
146
+ Scenario Outline: outline
147
+ Scenarios: another
148
+ |foo|bar|fan|
149
+ | 1 | 2 | 3 |
150
+ | 4 | 5 | 6 |
151
+ Scenarios: yet
152
+ |foo|bar|fan|
153
+ | 1 | 2 | 3 |
154
+ | 4 | 5 | 6 |
155
+ @s_o_tag
156
+ Feature: foo
157
+ Scenario Outline: outline
158
+ Scenarios: another
159
+ |foo|bar|fan|
160
+ | 1 | 2 | 3 |
161
+ | 4 | 5 | 6 |
162
+ Scenarios: yet
163
+ |foo|bar|fan|
164
+ | 1 | 2 | 3 |
165
+ | 4 | 5 | 6 |
166
+ @smoke
167
+ Feature: foo
168
+ Scenario Outline: outline
169
+ Scenarios: yet
170
+ |foo|bar|fan|
171
+ | 1 | 2 | 3 |
172
+ | 4 | 5 | 6 |
173
+ EOF
174
+ end
175
+ end
176
+ end
177
+
178
+ context "1 scenario and 1 outline with 2 examples" do
179
+ context "1 scenario tag, 1 outline tag" do
180
+ it "returns 2 tags, 1 with a scenario, 1 with an outline" do
181
+ report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_scenario_tag_1_outline_tag.feature")
182
+ report.should == <<EOF
183
+ @s_o_tag
184
+ Feature: foo
185
+ Scenario Outline: outline
186
+ Scenarios: another
187
+ |foo|bar|fan|
188
+ | 1 | 2 | 3 |
189
+ | 4 | 5 | 6 |
190
+ Scenarios: yet
191
+ |foo|bar|fan|
192
+ | 1 | 2 | 3 |
193
+ | 4 | 5 | 6 |
194
+ @s_tag
195
+ Feature: foo
196
+ Scenario: oh
197
+ EOF
198
+ end
199
+ end
200
+
201
+ context "1 scenario tag, 1 example tag" do
202
+ it "returns 2 tags, 1 with a scenario and 1 with an outline" do
203
+ report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_scenario_tag_1_example_tag.feature")
204
+ report.should == <<EOF
205
+ @s_o_tag
206
+ Feature: foo
207
+ Scenario Outline: outline
208
+ Scenarios: another
209
+ |foo|bar|fan|
210
+ | 1 | 2 | 3 |
211
+ | 4 | 5 | 6 |
212
+ @s_tag
213
+ Feature: foo
214
+ Scenario: oh
215
+ EOF
216
+ end
217
+ end
218
+
219
+ context "1 feature tag, 1 example tag" do
220
+ it "returns 2 tags" do
221
+ report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_feature_tag_1_example_tag.feature")
222
+ report.should == <<EOF
223
+ @example_tag
224
+ Feature: foo
225
+ Scenario Outline: outline
226
+ Scenarios: another
227
+ |foo|bar|fan|
228
+ | 1 | 2 | 3 |
229
+ | 4 | 5 | 6 |
230
+ @f_tag
231
+ Feature: foo
232
+ Scenario: oh
233
+ Scenario Outline: outline
234
+ Scenarios: another
235
+ |foo|bar|fan|
236
+ | 1 | 2 | 3 |
237
+ | 4 | 5 | 6 |
238
+ Scenarios: yet
239
+ |foo|bar|fan|
240
+ | 1 | 2 | 3 |
241
+ | 4 | 5 | 6 |
242
+ EOF
243
+
244
+ end
245
+ end
246
+
247
+ context "1 feature tag, 2 scenario tags, 1 outline tag, 1 example tag" do
248
+ it "returns 5 tags" do
249
+ report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_feature_tag_2_scenario_tags_1_outline_tag_1_example_tag.feature")
250
+ report.should == <<EOF
251
+ @e_tag
252
+ Feature: foo
253
+ Scenario Outline: outline
254
+ Scenarios: yet
255
+ |foo|bar|fan|
256
+ | 1 | 2 | 3 |
257
+ | 4 | 5 | 6 |
258
+ @f_tag
259
+ Feature: foo
260
+ Scenario: oh
261
+ Scenario Outline: outline
262
+ Scenarios: another
263
+ |foo|bar|fan|
264
+ | 1 | 2 | 3 |
265
+ | 4 | 5 | 6 |
266
+ Scenarios: yet
267
+ |foo|bar|fan|
268
+ | 1 | 2 | 3 |
269
+ | 4 | 5 | 6 |
270
+ @o_tag
271
+ Feature: foo
272
+ Scenario Outline: outline
273
+ Scenarios: another
274
+ |foo|bar|fan|
275
+ | 1 | 2 | 3 |
276
+ | 4 | 5 | 6 |
277
+ Scenarios: yet
278
+ |foo|bar|fan|
279
+ | 1 | 2 | 3 |
280
+ | 4 | 5 | 6 |
281
+ @s_tag
282
+ Feature: foo
283
+ Scenario: oh
284
+ @wip
285
+ Feature: foo
286
+ Scenario: oh
287
+ EOF
288
+ end
289
+ end
290
+
291
+ end
292
+
293
+ context "2 outlines 1 scenario" do
294
+ context "2 outline tags, 1 scenario tag, 1 example tag" do
295
+ it "returns 4 tags" do
296
+ report = one_feature( "fixtures/2_outlines_1_scenario/2_outline_tags_1_scenario_tag_1_example_tag.feature")
297
+ report.should == <<EOF
298
+ @e_tag
299
+ Feature: foo
300
+ Scenario Outline: outline 2
301
+ Scenarios: yet
302
+ |foo|bar|fan|
303
+ | 1 | 2 | 3 |
304
+ | 4 | 5 | 6 |
305
+ @s_o_tag_1
306
+ Feature: foo
307
+ Scenario Outline: outline 1
308
+ Scenarios: example
309
+ |foo|bar|fan|
310
+ | 1 | 2 | 3 |
311
+ | 4 | 5 | 6 |
312
+ @s_o_tag_2
313
+ Feature: foo
314
+ Scenario Outline: outline 2
315
+ Scenarios: another
316
+ |foo|bar|fan|
317
+ | 1 | 2 | 3 |
318
+ | 4 | 5 | 6 |
319
+ Scenarios: yet
320
+ |foo|bar|fan|
321
+ | 1 | 2 | 3 |
322
+ | 4 | 5 | 6 |
323
+ @wip
324
+ Feature: foo
325
+ Scenario: oh
326
+ EOF
327
+ end
328
+ end
329
+
330
+ context "2 outline tags, 2 example tags, 2 empty example names" do
331
+ it "returns 4 tags" do
332
+ report = one_feature( "fixtures/2_outlines_1_scenario/empty_example_name.feature")
333
+ report.should == <<EOF
334
+ @e_tag
335
+ Feature: foo
336
+ Scenario Outline: outline 2
337
+ Examples:
338
+ |foo|bar|fan|
339
+ | 1 | 2 | 3 |
340
+ | 4 | 5 | 6 |
341
+ @nameless
342
+ Feature: foo
343
+ Scenario Outline: outline 1
344
+ Scenarios:
345
+ |foo|bar|fan|
346
+ | 1 | 2 | 3 |
347
+ | 4 | 5 | 6 |
348
+ @s_o_tag_1
349
+ Feature: foo
350
+ Scenario Outline: outline 1
351
+ Scenarios:
352
+ |foo|bar|fan|
353
+ | 1 | 2 | 3 |
354
+ | 4 | 5 | 6 |
355
+ Scenarios: example set 2
356
+ |foo|bar|fan|
357
+ | 5 | 6 | 7 |
358
+ | 8 | 9 | 0 |
359
+ @s_o_tag_2
360
+ Feature: foo
361
+ Scenario Outline: outline 2
362
+ Examples:
363
+ |foo|bar|fan|
364
+ | 1 | 2 | 3 |
365
+ | 4 | 5 | 6 |
366
+ Examples: another
367
+ |foo|bar|fan|
368
+ | 1 | 2 | 3 |
369
+ | 4 | 5 | 6 |
370
+ EOF
371
+ end
372
+ end
373
+ end
374
+
375
+ context "scenario outlines only" do
376
+ context "3 outlines" do
377
+ it "includes all outlines" do
378
+ report = one_feature( "fixtures/3_scenario_outlines.feature")
379
+ report.should == <<EOF
380
+ @blocked
381
+ Feature: foo
382
+ Scenario Outline: outline 2
383
+ Scenarios: another
384
+ |foo|bar|fan|
385
+ | 1 | 2 | 3 |
386
+ | 4 | 5 | 6 |
387
+ @e_tag
388
+ Feature: foo
389
+ Scenario Outline: outline 3
390
+ Scenarios: yet
391
+ |foo|bar|fan|
392
+ | 1 | 2 | 3 |
393
+ | 4 | 5 | 6 |
394
+ @s_o_tag_1
395
+ Feature: foo
396
+ Scenario Outline: outline 1
397
+ Scenarios: example
398
+ |foo|bar|fan|
399
+ | 1 | 2 | 3 |
400
+ | 4 | 5 | 6 |
401
+ @s_o_tag_3
402
+ Feature: foo
403
+ Scenario Outline: outline 3
404
+ Scenarios: another
405
+ |foo|bar|fan|
406
+ | 1 | 2 | 3 |
407
+ | 4 | 5 | 6 |
408
+ Scenarios: yet
409
+ |foo|bar|fan|
410
+ | 1 | 2 | 3 |
411
+ | 4 | 5 | 6 |
412
+ @wip
413
+ Feature: foo
414
+ Scenario Outline: outline 2
415
+ Scenarios: another
416
+ |foo|bar|fan|
417
+ | 1 | 2 | 3 |
418
+ | 4 | 5 | 6 |
419
+ Scenarios: yet
420
+ |foo|bar|fan|
421
+ | 1 | 2 | 3 |
422
+ | 4 | 5 | 6 |
423
+ EOF
424
+ end
425
+ end
426
+
427
+ end
428
+
429
+ end
430
+ end
431
+
@@ -49,300 +49,6 @@ EOF
49
49
  end
50
50
  end
51
51
 
52
- context "one scenario tag one feature tag" do
53
- it "returns two tags, one mapped to one scenario, the other mapped to two" do
54
- report = one_feature( "fixtures/one_scenario_tag_one_feature_tag.feature")
55
- report.should == <<EOF
56
- @customer_module
57
- Feature: foo
58
- Scenario: another test
59
- Scenario: some test of something
60
- @smoke
61
- Feature: foo
62
- Scenario: another test
63
- EOF
64
- end
65
- end
66
-
67
-
68
- context "scenario outline with 2 examples" do
69
- context "1 example tag" do
70
- it "returns 1 tag mapped to 1 example" do
71
- report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag.feature")
72
- report.should == <<EOF
73
- @smoke
74
- Feature: foo
75
- Scenario Outline: outline
76
- Scenarios: bang
77
- EOF
78
- end
79
- end
80
-
81
- context "1 tag per example" do
82
- it "returns 2 examples mapped to a tag" do
83
- report = one_feature( "fixtures/scenario_outline_with_2_examples/1_tag_per_example.feature")
84
- report.should == <<EOF
85
- @smoke
86
- Feature: foo
87
- Scenario Outline: some
88
- Scenarios: yet
89
- @wip
90
- Feature: foo
91
- Scenario Outline: some
92
- Scenarios: another
93
- EOF
94
- end
95
- end
96
-
97
- context "1 tag per example, 2 feature tags" do
98
- it "returns 4 tags . . ." do
99
- report = one_feature( "fixtures/scenario_outline_with_2_examples/1_tag_per_example_2_feature_tags.feature")
100
- report.should == <<EOF
101
- @smoke
102
- Feature: foo
103
- Scenario Outline: outline
104
- Scenarios: yet
105
- @taggy
106
- Feature: foo
107
- Scenario Outline: outline
108
- Scenarios: another
109
- Scenarios: yet
110
- @waggy
111
- Feature: foo
112
- Scenario Outline: outline
113
- Scenarios: another
114
- Scenarios: yet
115
- @wip
116
- Feature: foo
117
- Scenario Outline: outline
118
- Scenarios: another
119
- EOF
120
- end
121
- end
122
-
123
- context "1 example tag and 1 feature tag" do
124
- it "returns 2 tags" do
125
- report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_and_1_feature_tag.feature")
126
- report.should == <<EOF
127
- @f_tag
128
- Feature: foo
129
- Scenario Outline: outline
130
- Scenarios: another
131
- Scenarios: yet
132
- @smoke
133
- Feature: foo
134
- Scenario Outline: outline
135
- Scenarios: yet
136
- EOF
137
- end
138
- end
139
-
140
- context "1 example tag and 1 scenario outline tag" do
141
- it "returns 1 example mapped to 1 tag" do
142
- report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_and_1_scenario_outline_tag.feature")
143
- report.should == <<EOF
144
- @s_o_tag
145
- Feature: foo
146
- Scenario Outline: outline
147
- Scenarios: another
148
- Scenarios: yet
149
- @smoke
150
- Feature: foo
151
- Scenario Outline: outline
152
- Scenarios: yet
153
- EOF
154
- end
155
- end
156
- context "1 example tag, 1 scenario outline tag, 1 feature tag" do
157
- it "3 tags" do
158
- report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_1_scenario_outline_tag_1_feature_tag.feature")
159
- report.should == <<EOF
160
- @f_tag
161
- Feature: foo
162
- Scenario Outline: outline
163
- Scenarios: another
164
- Scenarios: yet
165
- @s_o_tag
166
- Feature: foo
167
- Scenario Outline: outline
168
- Scenarios: another
169
- Scenarios: yet
170
- @smoke
171
- Feature: foo
172
- Scenario Outline: outline
173
- Scenarios: yet
174
- EOF
175
- end
176
- end
177
- end
178
-
179
- context "1 scenario and 1 outline with 2 examples" do
180
- context "1 scenario tag, 1 outline tag" do
181
- it "returns 2 tags, 1 with a scenario, 1 with an outline" do
182
- report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_scenario_tag_1_outline_tag.feature")
183
- report.should == <<EOF
184
- @s_o_tag
185
- Feature: foo
186
- Scenario Outline: outline
187
- Scenarios: another
188
- Scenarios: yet
189
- @s_tag
190
- Feature: foo
191
- Scenario: oh
192
- EOF
193
- end
194
- end
195
-
196
- context "1 scenario tag, 1 example tag" do
197
- it "returns 2 tags, 1 with a scenario and 1 with an outline" do
198
- report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_scenario_tag_1_example_tag.feature")
199
- report.should == <<EOF
200
- @s_o_tag
201
- Feature: foo
202
- Scenario Outline: outline
203
- Scenarios: another
204
- @s_tag
205
- Feature: foo
206
- Scenario: oh
207
- EOF
208
- end
209
- end
210
-
211
- context "1 feature tag, 1 example tag" do
212
- it "returns 2 tags" do
213
- report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_feature_tag_1_example_tag.feature")
214
- report.should == <<EOF
215
- @example_tag
216
- Feature: foo
217
- Scenario Outline: outline
218
- Scenarios: another
219
- @f_tag
220
- Feature: foo
221
- Scenario: oh
222
- Scenario Outline: outline
223
- Scenarios: another
224
- Scenarios: yet
225
- EOF
226
-
227
- end
228
- end
229
-
230
- context "1 feature tag, 2 scenario tags, 1 outline tag, 1 example tag" do
231
- it "returns 5 tags" do
232
- report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_feature_tag_2_scenario_tags_1_outline_tag_1_example_tag.feature")
233
- report.should == <<EOF
234
- @e_tag
235
- Feature: foo
236
- Scenario Outline: outline
237
- Scenarios: yet
238
- @f_tag
239
- Feature: foo
240
- Scenario: oh
241
- Scenario Outline: outline
242
- Scenarios: another
243
- Scenarios: yet
244
- @o_tag
245
- Feature: foo
246
- Scenario Outline: outline
247
- Scenarios: another
248
- Scenarios: yet
249
- @s_tag
250
- Feature: foo
251
- Scenario: oh
252
- @wip
253
- Feature: foo
254
- Scenario: oh
255
- EOF
256
- end
257
- end
258
-
259
- end
260
-
261
- context "2 outlines 1 scenario" do
262
- context "2 outline tags, 1 scenario tag, 1 example tag" do
263
- it "returns 4 tags" do
264
- report = one_feature( "fixtures/2_outlines_1_scenario/2_outline_tags_1_scenario_tag_1_example_tag.feature")
265
- report.should == <<EOF
266
- @e_tag
267
- Feature: foo
268
- Scenario Outline: outline 2
269
- Scenarios: yet
270
- @s_o_tag_1
271
- Feature: foo
272
- Scenario Outline: outline 1
273
- Scenarios: example
274
- @s_o_tag_2
275
- Feature: foo
276
- Scenario Outline: outline 2
277
- Scenarios: another
278
- Scenarios: yet
279
- @wip
280
- Feature: foo
281
- Scenario: oh
282
- EOF
283
- end
284
- end
285
-
286
- context "2 outline tags, 2 example tag, 2 empty example names" do
287
- it "returns 4 tags" do
288
- report = one_feature( "fixtures/2_outlines_1_scenario/empty_example_name.feature")
289
- report.should == <<EOF
290
- @e_tag
291
- Feature: foo
292
- Scenario Outline: outline 2
293
- Examples:
294
- @nameless
295
- Feature: foo
296
- Scenario Outline: outline 1
297
- Scenarios:
298
- @s_o_tag_1
299
- Feature: foo
300
- Scenario Outline: outline 1
301
- Scenarios:
302
- Scenarios: example set 2
303
- @s_o_tag_2
304
- Feature: foo
305
- Scenario Outline: outline 2
306
- Examples:
307
- Examples: another
308
- EOF
309
- end
310
- end
311
- end
312
-
313
- context "scenario outlines only" do
314
- context "3 outlines" do
315
- it "includes all outlines" do
316
- report = one_feature( "fixtures/3_scenario_outlines.feature")
317
- report.should == <<EOF
318
- @blocked
319
- Feature: foo
320
- Scenario Outline: outline 2
321
- Scenarios: another
322
- @e_tag
323
- Feature: foo
324
- Scenario Outline: outline 3
325
- Scenarios: yet
326
- @s_o_tag_1
327
- Feature: foo
328
- Scenario Outline: outline 1
329
- Scenarios: example
330
- @s_o_tag_3
331
- Feature: foo
332
- Scenario Outline: outline 3
333
- Scenarios: another
334
- Scenarios: yet
335
- @wip
336
- Feature: foo
337
- Scenario Outline: outline 2
338
- Scenarios: another
339
- Scenarios: yet
340
- EOF
341
- end
342
- end
343
-
344
- end
345
-
346
52
  end
347
53
  end
348
54
 
@@ -9,12 +9,12 @@ module Cuporter
9
9
  end
10
10
 
11
11
  it 'has an empty tag list' do
12
- tag_list_node.should_not have_universal_tags
12
+ tag_list_node.should_not have_tags
13
13
  end
14
14
  context 'with tags' do
15
15
  it 'should have tags' do
16
16
  tag_list_node = TagListNode.new("name", %w[tag_1 tag_2])
17
- tag_list_node.should have_universal_tags
17
+ tag_list_node.should have_tags
18
18
  end
19
19
  end
20
20
  end
@@ -23,7 +23,7 @@ module Cuporter
23
23
  context 'with universal tags but none of their own' do
24
24
  it 'child inherits one tag from parent' do
25
25
  tag_list_node = TagListNode.new("parent", ["p_tag_1"])
26
- tag_list_node.add_to_tag_node(Node.new("child"))
26
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child", []))
27
27
 
28
28
  tag_list_node.children.size.should == 1
29
29
  tag_list_node.children.first.name.should == "p_tag_1"
@@ -34,7 +34,7 @@ module Cuporter
34
34
  end
35
35
  it 'child inherits 2 tags from parent' do
36
36
  tag_list_node = TagListNode.new("parent", ["p_tag_1", "p_tag_2"])
37
- tag_list_node.add_to_tag_node(Node.new("child"))
37
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child", []))
38
38
 
39
39
  tag_list_node.children.size.should == 2
40
40
  tag_list_node.children.first.name.should == "p_tag_1"
@@ -51,7 +51,7 @@ module Cuporter
51
51
  context 'without universal tags but some of their own' do
52
52
  let(:tag_list_node) {TagListNode.new("parent", []) }
53
53
  it 'child has one tag' do
54
- tag_list_node.add_to_tag_node(Node.new("child"), ["c_tag_1"])
54
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child", ["c_tag_1"]))
55
55
 
56
56
  tag_list_node.children.size.should == 1
57
57
  tag_list_node.children.first.name.should == "c_tag_1"
@@ -60,7 +60,7 @@ module Cuporter
60
60
  tag_list_node[:c_tag_1].children.first.name.should == "child"
61
61
  end
62
62
  it 'child has two tags' do
63
- tag_list_node.add_to_tag_node(Node.new("child"), ["c_tag_1", "c_tag_2"])
63
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child", ["c_tag_1", "c_tag_2"]))
64
64
 
65
65
  tag_list_node.children.size.should == 2
66
66
  tag_list_node.children.first.name.should == "c_tag_1"
@@ -76,7 +76,7 @@ module Cuporter
76
76
  context 'with universal tags and their own tags' do
77
77
  let(:tag_list_node) {TagListNode.new("parent",%w[p_tag_1 p_tag_2]) }
78
78
  it "2 universal tags and 2 child tags" do
79
- tag_list_node.add_to_tag_node(Node.new("child"), ["c_tag_1", "c_tag_2"])
79
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child", ["c_tag_1", "c_tag_2"]))
80
80
 
81
81
  tag_list_node.children.size.should == 4
82
82
  tag_list_node.children.collect do |c|
@@ -99,7 +99,7 @@ module Cuporter
99
99
  context 'with no tags at all' do
100
100
  it 'top node has no children' do
101
101
  tag_list_node = TagListNode.new("parent", [])
102
- tag_list_node.add_to_tag_node(Node.new("child"))
102
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child", []))
103
103
 
104
104
  tag_list_node.should_not have_children
105
105
 
@@ -110,8 +110,8 @@ module Cuporter
110
110
  context 'second child with preexisting tag' do
111
111
  it 'top node has 1 child and 2 grandchildren' do
112
112
  tag_list_node = TagListNode.new("parent", ["p_tag_1"])
113
- tag_list_node.add_to_tag_node(Node.new("child_1"))
114
- tag_list_node.add_to_tag_node(Node.new("child_2"))
113
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child_1", []))
114
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child_2", []))
115
115
 
116
116
  tag_list_node.children.size.should == 1
117
117
  tag_list_node.children[0].name.should == "p_tag_1"
@@ -123,8 +123,8 @@ module Cuporter
123
123
 
124
124
  it '2 child nodes with 1 universal tag and 2 child tags' do
125
125
  tag_list_node = TagListNode.new("parent", ["p_tag_1"])
126
- tag_list_node.add_to_tag_node(Node.new("child_1"), ["c_tag_1"])
127
- tag_list_node.add_to_tag_node(Node.new("child_2"), ["c_tag_1", "c_tag_2"])
126
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child_1", ["c_tag_1"]))
127
+ tag_list_node.add_to_tag_nodes(TagListNode.new("child_2", ["c_tag_1", "c_tag_2"]))
128
128
 
129
129
  tag_list_node.children.size.should == 3
130
130
  tag_list_node.children[0].name.should == "p_tag_1"
@@ -150,16 +150,16 @@ module Cuporter
150
150
  it 'top node has no children' do
151
151
  p = TagListNode.new("parent", ["p_tag_1"])
152
152
  c = TagListNode.new("child", [] )
153
- c.add_to_tag_node(Node.new("leaf_1"))
153
+ c.add_to_tag_nodes(TagListNode.new("leaf_1", []))
154
154
 
155
155
  p.should_not have_children
156
156
  end
157
157
 
158
158
  it 'all leaf nodes are under parent universal tag' do
159
159
  p = TagListNode.new("parent", ["p_tag_1"])
160
- c = TagListNode.new("child", p.universal_tags)
161
- c.add_to_tag_node(Node.new("leaf_1"))
162
- c.add_to_tag_node(Node.new("leaf_2"))
160
+ c = TagListNode.new("child", p.tags)
161
+ c.add_to_tag_nodes(TagListNode.new("leaf_1", []))
162
+ c.add_to_tag_nodes(TagListNode.new("leaf_2", []))
163
163
  p.merge(c)
164
164
 
165
165
  p.children.size.should == 1
@@ -181,9 +181,9 @@ module Cuporter
181
181
  context '1 universal tag on parent and 1 universal tag on child' do
182
182
  it "2 tags have 2 leaf nodes" do
183
183
  p = TagListNode.new("parent", ["p_tag_1"])
184
- c = TagListNode.new("child", p.universal_tags | ["c_tag_1"])
185
- c.add_to_tag_node(Node.new("leaf_1"))
186
- c.add_to_tag_node(Node.new("leaf_2"))
184
+ c = TagListNode.new("child", p.tags | ["c_tag_1"])
185
+ c.add_to_tag_nodes(TagListNode.new("leaf_1", []))
186
+ c.add_to_tag_nodes(TagListNode.new("leaf_2", []))
187
187
  p.merge(c)
188
188
 
189
189
  p.children.size.should == 2
@@ -213,9 +213,9 @@ module Cuporter
213
213
  context '1 universal tag on parent and 1 tag on 1 leaf' do
214
214
  it "1 tag has 1 leaf node, the other has 2 leaf nodes" do
215
215
  p = TagListNode.new("parent", ["p_tag_1"])
216
- c = TagListNode.new("child", p.universal_tags )
217
- c.add_to_tag_node(Node.new("leaf_1"))
218
- c.add_to_tag_node(Node.new("leaf_2"), ["l_tag_1"])
216
+ c = TagListNode.new("child", p.tags )
217
+ c.add_to_tag_nodes(TagListNode.new("leaf_1", []))
218
+ c.add_to_tag_nodes(TagListNode.new("leaf_2", ["l_tag_1"]))
219
219
  p.merge(c)
220
220
 
221
221
  p.children.size.should == 2
@@ -243,9 +243,9 @@ module Cuporter
243
243
  context '1 universal tag on parent 1 universal tag on child 1 tag on leaf' do
244
244
  it "2 tags with 2 leaves, 1 tag with 1 leaf" do
245
245
  p = TagListNode.new("parent", ["p_tag_1"])
246
- c = TagListNode.new("child", p.universal_tags | ["c_tag_1"])
247
- c.add_to_tag_node(Node.new("leaf_1"))
248
- c.add_to_tag_node(Node.new("leaf_2"), ["l_tag_1"])
246
+ c = TagListNode.new("child", p.tags | ["c_tag_1"])
247
+ c.add_to_tag_nodes(TagListNode.new("leaf_1", []))
248
+ c.add_to_tag_nodes(TagListNode.new("leaf_2", ["l_tag_1"]))
249
249
  p.merge(c)
250
250
 
251
251
  p.children.size.should == 3
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tim Camper
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-03 00:00:00 -05:00
17
+ date: 2010-09-05 00:00:00 -05:00
18
18
  default_executable: cuporter
19
19
  dependencies: []
20
20
 
@@ -31,6 +31,7 @@ files:
31
31
  - LICENSE
32
32
  - README.textile
33
33
  - Rakefile
34
+ - lib/cuporter/non_sorting_node.rb
34
35
  - lib/cuporter/formatters/csv.rb
35
36
  - lib/cuporter/formatters/text.rb
36
37
  - lib/cuporter/formatters/html.rb
@@ -46,6 +47,7 @@ files:
46
47
  - spec/cuporter/node_spec.rb
47
48
  - spec/cuporter/feature_parser_spec.rb
48
49
  - spec/cuporter/support/functional/cli.rb
50
+ - spec/cuporter/functional/scenario_outlines_spec.rb
49
51
  - spec/cuporter/functional/single_feature_spec.rb
50
52
  - spec/cuporter/tag_list_node_spec.rb
51
53
  - spec/spec_helper.rb