cucumber 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/History.txt +16 -0
  2. data/Manifest.txt +6 -0
  3. data/examples/i18n/he/Rakefile +6 -0
  4. data/examples/i18n/he/features/addition.feature +16 -0
  5. data/examples/i18n/he/features/division.feature +9 -0
  6. data/examples/i18n/he/features/step_definitons/calculator_steps.rb +24 -0
  7. data/examples/i18n/he/lib/calculator.rb +14 -0
  8. data/examples/self_test/features/search_sample.feature +10 -0
  9. data/examples/watir/features/search.feature +4 -1
  10. data/examples/watir/features/step_definitons/search_steps.rb +2 -4
  11. data/features/background.feature +30 -35
  12. data/features/cucumber_cli.feature +78 -68
  13. data/features/cucumber_cli_diff_disabled.feature +4 -4
  14. data/features/cucumber_cli_outlines.feature +43 -53
  15. data/features/multiline_names.feature +10 -10
  16. data/features/rake_task.feature +104 -86
  17. data/features/report_called_undefined_steps.feature +2 -2
  18. data/features/step_definitions/cucumber_steps.rb +8 -0
  19. data/features/usage.feature +1 -0
  20. data/lib/cucumber/ast/outline_table.rb +5 -0
  21. data/lib/cucumber/ast/scenario.rb +5 -0
  22. data/lib/cucumber/ast/step_collection.rb +7 -2
  23. data/lib/cucumber/ast/table.rb +1 -1
  24. data/lib/cucumber/formatter/console.rb +15 -9
  25. data/lib/cucumber/formatter/pretty.rb +3 -3
  26. data/lib/cucumber/formatter/progress.rb +8 -9
  27. data/lib/cucumber/languages.yml +16 -1
  28. data/lib/cucumber/parser/feature.rb +9 -2
  29. data/lib/cucumber/parser/feature.tt +13 -5
  30. data/lib/cucumber/parser/treetop_ext.rb +9 -0
  31. data/lib/cucumber/rails/world.rb +7 -1
  32. data/lib/cucumber/rake/task.rb +2 -0
  33. data/lib/cucumber/step_mother.rb +6 -1
  34. data/lib/cucumber/version.rb +1 -1
  35. data/spec/cucumber/ast/table_spec.rb +1 -1
  36. data/spec/cucumber/formatter/progress_spec.rb +35 -0
  37. data/spec/cucumber/parser/feature_parser_spec.rb +12 -0
  38. metadata +8 -2
@@ -80,6 +80,11 @@ module Cucumber
80
80
  @step_invocations.passed?
81
81
  end
82
82
 
83
+ # Returns the status
84
+ def status
85
+ @step_invocations.status
86
+ end
87
+
83
88
  private
84
89
 
85
90
  def header?
@@ -45,6 +45,11 @@ module Cucumber
45
45
  @steps.exception
46
46
  end
47
47
 
48
+ # Returns the status
49
+ def status
50
+ @steps.status
51
+ end
52
+
48
53
  def skip_invoke!
49
54
  @steps.each{|step_invocation| step_invocation.skip_invoke!}
50
55
  @feature.next_feature_element(self) do |next_one|
@@ -55,11 +55,16 @@ module Cucumber
55
55
  end
56
56
 
57
57
  def failed?
58
- @steps.detect{|step_invocation| step_invocation.status == :failed}
58
+ status == :failed
59
59
  end
60
60
 
61
61
  def passed?
62
- @steps.detect{|step_invocation| step_invocation.status != :passed}.nil?
62
+ status == :passed
63
+ end
64
+
65
+ def status
66
+ @steps.each{|step_invocation| return step_invocation.status if step_invocation.status != :passed}
67
+ :passed
63
68
  end
64
69
 
65
70
  def to_sexp
@@ -192,7 +192,7 @@ module Cucumber
192
192
  end
193
193
 
194
194
  def has_text?(text)
195
- raw.flatten.detect{|cell_value| cell_value.index(text)}
195
+ raw.flatten.compact.detect{|cell_value| cell_value.index(text)}
196
196
  end
197
197
 
198
198
  def cells_rows
@@ -51,17 +51,15 @@ module Cucumber
51
51
  end
52
52
 
53
53
  def print_counts
54
- @io.puts dump_count(step_mother.scenarios.length, "scenario")
54
+ @io.print dump_count(step_mother.scenarios.length, "scenario")
55
+ print_status_counts{|status| step_mother.scenarios(status)}
55
56
 
56
- [:failed, :skipped, :undefined, :pending, :passed].each do |status|
57
- if step_mother.steps(status).any?
58
- count_string = dump_count(step_mother.steps(status).length, "step", status.to_s)
59
- @io.puts format_string(count_string, status)
60
- @io.flush
61
- end
62
- end
63
- end
57
+ @io.print dump_count(step_mother.steps.length, "step")
58
+ print_status_counts{|status| step_mother.steps(status)}
64
59
 
60
+ @io.flush
61
+ end
62
+
65
63
  def print_exception(e, status, indent)
66
64
  if @options[:strict] || !(Undefined === e) || e.nested?
67
65
  @io.puts(format_string("#{e.message} (#{e.class})\n#{e.backtrace.join("\n")}".indent(indent), status))
@@ -95,6 +93,14 @@ module Cucumber
95
93
 
96
94
  private
97
95
 
96
+ def print_status_counts
97
+ counts = [:failed, :skipped, :undefined, :pending, :passed].map do |status|
98
+ elements = yield status
99
+ elements.any? ? format_string("#{elements.length} #{status.to_s}", status) : nil
100
+ end
101
+ @io.puts(" (#{counts.compact.join(', ')})")
102
+ end
103
+
98
104
  def dump_count(count, what, state=nil)
99
105
  [count, state, "#{what}#{count == 1 ? '' : 's'}"].compact.join(" ")
100
106
  end
@@ -96,10 +96,10 @@ module Cucumber
96
96
 
97
97
  def visit_examples_name(keyword, name)
98
98
  names = name.empty? ? [name] : name.split("\n")
99
- @io.puts("\n #{keyword} #{names[0]}")
100
- names[1..-1].each {|s| @io.puts " #{s}" }
99
+ @io.puts("\n #{keyword} #{names[0]}")
100
+ names[1..-1].each {|s| @io.puts " #{s}" }
101
101
  @io.flush
102
- @indent = 4
102
+ @indent = 6
103
103
  end
104
104
 
105
105
  def visit_scenario_name(keyword, name, file_colon_line, source_indent)
@@ -18,18 +18,14 @@ module Cucumber
18
18
  print_summary
19
19
  end
20
20
 
21
- def visit_multiline_arg(multiline_arg)
22
- @multiline_arg = true
23
- super
24
- @multiline_arg = false
25
- end
26
-
27
- def visit_step_name(keyword, step_match, status, source_indent, background)
28
- progress(status) unless status == :outline
21
+ def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
22
+ progress(status)
23
+ @status = status
29
24
  end
30
25
 
31
26
  def visit_table_cell_value(value, width, status)
32
- progress(status) if (status != :thead) && !@multiline_arg
27
+ status ||= @status
28
+ progress(status) unless table_header_cell?(status)
33
29
  end
34
30
 
35
31
  private
@@ -55,6 +51,9 @@ module Cucumber
55
51
  @io.flush
56
52
  end
57
53
 
54
+ def table_header_cell?(status)
55
+ status == :skipped_param
56
+ end
58
57
  end
59
58
  end
60
59
  end
@@ -206,6 +206,21 @@
206
206
  and: Et
207
207
  but: Mais
208
208
  space_after_keyword: true
209
+ "he":
210
+ name: Hebrew
211
+ native: עברית
212
+ encoding: UTF-8
213
+ feature: תכונה
214
+ background: רקע
215
+ scenario: תרחיש
216
+ scenario_outline: תבנית תרחיש
217
+ examples: דוגמאות
218
+ given: בהינתן
219
+ when: כאשר
220
+ then: אז|אזי
221
+ and: וגם
222
+ but: אבל
223
+ space_after_keyword: true
209
224
  "hu":
210
225
  name: Hungarian
211
226
  native: magyar
@@ -482,4 +497,4 @@
482
497
  then: То
483
498
  and: И
484
499
  but: Но
485
- space_after_keyword: true
500
+ space_after_keyword: true
@@ -827,6 +827,10 @@ module Cucumber
827
827
  end
828
828
 
829
829
  def matches_name?(regexp_to_match)
830
+ outline_matches_name?(regexp_to_match) || examples_sections.matches_name?(regexp_to_match)
831
+ end
832
+
833
+ def outline_matches_name?(regexp_to_match)
830
834
  name.build =~ regexp_to_match
831
835
  end
832
836
 
@@ -1088,9 +1092,13 @@ module Cucumber
1088
1092
  elements.detect { |e| e.at_line?(line) }
1089
1093
  end
1090
1094
 
1095
+ def matches_name?(regexp_to_match)
1096
+ elements.detect { |e| e.matches_name?(regexp_to_match) }
1097
+ end
1098
+
1091
1099
  def build(filter, scenario_outline)
1092
1100
  elements.map do |e|
1093
- if(filter.nil? || filter.accept?(e) || filter.outline_at_line?(scenario_outline))
1101
+ if(filter.nil? || filter.accept_example?(e, scenario_outline))
1094
1102
  e.build(filter, scenario_outline)
1095
1103
  end
1096
1104
  end.compact
@@ -1474,7 +1482,6 @@ module Cucumber
1474
1482
  end
1475
1483
 
1476
1484
  module LinesToKeyword0
1477
-
1478
1485
  def build
1479
1486
  elements.map{|s| s.build}.join("\n")
1480
1487
  end
@@ -165,6 +165,10 @@ module Cucumber
165
165
  end
166
166
 
167
167
  def matches_name?(regexp_to_match)
168
+ outline_matches_name?(regexp_to_match) || examples_sections.matches_name?(regexp_to_match)
169
+ end
170
+
171
+ def outline_matches_name?(regexp_to_match)
168
172
  name.build =~ regexp_to_match
169
173
  end
170
174
 
@@ -218,9 +222,13 @@ module Cucumber
218
222
  elements.detect { |e| e.at_line?(line) }
219
223
  end
220
224
 
225
+ def matches_name?(regexp_to_match)
226
+ elements.detect { |e| e.matches_name?(regexp_to_match) }
227
+ end
228
+
221
229
  def build(filter, scenario_outline)
222
230
  elements.map do |e|
223
- if(filter.nil? || filter.accept?(e) || filter.outline_at_line?(scenario_outline))
231
+ if(filter.nil? || filter.accept_example?(e, scenario_outline))
224
232
  e.build(filter, scenario_outline)
225
233
  end
226
234
  end.compact
@@ -270,10 +278,10 @@ module Cucumber
270
278
  end
271
279
 
272
280
  rule lines_to_keyword
273
- (line_to_keyword)* {
274
- def build
275
- elements.map{|s| s.build}.join("\n")
276
- end
281
+ line_to_keyword* {
282
+ def build
283
+ elements.map{|s| s.build}.join("\n")
284
+ end
277
285
  }
278
286
  end
279
287
 
@@ -26,6 +26,11 @@ module Cucumber
26
26
  matches_names?(syntax_node)
27
27
  end
28
28
 
29
+ def accept_example?(syntax_node, outline)
30
+ (at_line?(syntax_node) || outline_at_line?(outline)) &&
31
+ (matches_names?(syntax_node) || outline_matches_names?(outline))
32
+ end
33
+
29
34
  def at_line?(syntax_node)
30
35
  @lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.at_line?(line)}
31
36
  end
@@ -47,6 +52,10 @@ module Cucumber
47
52
  @exclude_tags.any? && syntax_node.has_tags?(@exclude_tags)
48
53
  end
49
54
 
55
+ def outline_matches_names?(syntax_node)
56
+ @name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.outline_matches_name?(name_regexp)}
57
+ end
58
+
50
59
  def matches_names?(syntax_node)
51
60
  @name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.matches_name?(name_regexp)}
52
61
  end
@@ -7,8 +7,14 @@ else
7
7
  require 'action_controller/test_process'
8
8
  require 'action_controller/integration'
9
9
  end
10
- require 'test/unit/testresult'
11
10
 
11
+ begin
12
+ require 'test/unit/testresult'
13
+ rescue LoadError => e
14
+ e.message << "\nYou must gem install test-unit. For more info see https://rspec.lighthouseapp.com/projects/16211/tickets/292"
15
+ e.message << "\nAlso make sure you have rack 1.0.0 or higher."
16
+ raise e
17
+ end
12
18
 
13
19
  # So that Test::Unit doesn't launch at the end - makes it think it has already been run.
14
20
  Test::Unit.run = true if Test::Unit.respond_to?(:run=)
@@ -62,6 +62,8 @@ module Cucumber
62
62
  def profile=(profile)
63
63
  @profile = profile
64
64
  unless feature_list
65
+ # TODO: remove once we completely remove these from the rake task.
66
+ @step_list = []
65
67
  @feature_list = [] # Don't use accessor to avoid deprecation warning.
66
68
  end
67
69
  end
@@ -105,8 +105,13 @@ module Cucumber
105
105
  end
106
106
  end
107
107
 
108
- def scenarios
108
+ def scenarios(status = nil)
109
109
  @scenarios ||= []
110
+ if(status)
111
+ @scenarios.select{|scenario| scenario.status == status}
112
+ else
113
+ @scenarios
114
+ end
110
115
  end
111
116
 
112
117
  # Registers a new StepDefinition. This method is aliased
@@ -2,7 +2,7 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 2
6
6
  PATCH = nil # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
@@ -129,7 +129,7 @@ module Cucumber
129
129
  it "should recognise when just a subset of a cell is delimited" do
130
130
  table = Table.new([
131
131
  %w{qty book},
132
- ['<qty>', "This is <who>'s book"]
132
+ [nil, "This is <who>'s book"]
133
133
  ])
134
134
  table.should have_text('<who>')
135
135
  end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Cucumber
4
+ module Formatter
5
+ describe Progress do
6
+
7
+ before(:all) do
8
+ Term::ANSIColor.coloring = false
9
+ end
10
+
11
+ before(:each) do
12
+ @out = StringIO.new
13
+ @progress = Progress.new(mock("step mother"), @out, {})
14
+ end
15
+
16
+ describe "visiting a table cell value without a status" do
17
+ it "should take the status from the last run step" do
18
+ @progress.visit_step_result('', '', nil, :failed, nil, 10, nil)
19
+ @progress.visit_table_cell_value('value', 10, nil)
20
+
21
+ @out.string.should == "FF"
22
+ end
23
+ end
24
+
25
+ describe "visiting a table cell which is a table header" do
26
+ it "should not output anything" do
27
+ @progress.visit_table_cell_value('value', 10, :skipped_param)
28
+
29
+ @out.string.should == ""
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -304,6 +304,18 @@ Examples: I'm a multiline name
304
304
  [:row, 8,
305
305
  [:cell, "5"]]]]]]
306
306
  end
307
+
308
+ it "should allow Examples to have multiline names" do
309
+ pending('https://rspec.lighthouseapp.com/projects/16211/tickets/307-031-step-mother-parses-scenario-titles') do
310
+ parse(%{Feature: Hi
311
+ Scenario: When I have when in scenario
312
+ Given I am a step
313
+ }).to_sexp.should ==
314
+ [:feature, nil, "Feature: Hi",
315
+ [:scenario, 2, "Scenario:", "When I have when in scenario",
316
+ [:step, 3, "Given", "I am a step"]]]
317
+ end
318
+ end
307
319
  end
308
320
 
309
321
  describe "Syntax" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-26 00:00:00 +02:00
12
+ date: 2009-05-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -144,6 +144,11 @@ files:
144
144
  - examples/i18n/fr/features/addition.feature
145
145
  - examples/i18n/fr/features/step_definitions/calculatrice_steps.rb
146
146
  - examples/i18n/fr/lib/calculatrice.rb
147
+ - examples/i18n/he/Rakefile
148
+ - examples/i18n/he/features/addition.feature
149
+ - examples/i18n/he/features/division.feature
150
+ - examples/i18n/he/features/step_definitons/calculator_steps.rb
151
+ - examples/i18n/he/lib/calculator.rb
147
152
  - examples/i18n/hu/Rakefile
148
153
  - examples/i18n/hu/features/addition.feature
149
154
  - examples/i18n/hu/features/division.feature
@@ -418,6 +423,7 @@ files:
418
423
  - spec/cucumber/formatter/html/index.html
419
424
  - spec/cucumber/formatter/html/jquery-1.3.min.js
420
425
  - spec/cucumber/formatter/html/jquery.uitableedit.js
426
+ - spec/cucumber/formatter/progress_spec.rb
421
427
  - spec/cucumber/parser/feature_parser_spec.rb
422
428
  - spec/cucumber/parser/table_parser_spec.rb
423
429
  - spec/cucumber/rails/stubs/mini_rails.rb