cucumber 1.1.9 → 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 (53) hide show
  1. data/.travis.yml +9 -0
  2. data/History.md +20 -3
  3. data/README.md +1 -2
  4. data/cucumber.gemspec +10 -13
  5. data/cucumber.yml +2 -2
  6. data/features/.cucumber/stepdefs.json +13 -391
  7. data/features/backtraces.feature +36 -0
  8. data/features/{issue_117.feature → drb_server_integration.feature} +3 -3
  9. data/features/formatter_step_file_colon_line.feature +46 -0
  10. data/features/{issue_57.feature → rerun_formatter.feature} +2 -2
  11. data/features/run_specific_scenarios.feature +47 -0
  12. data/gem_tasks/cucumber.rake +15 -8
  13. data/legacy_features/cucumber_cli.feature +0 -7
  14. data/legacy_features/junit_formatter.feature +60 -10
  15. data/legacy_features/language_help.feature +1 -0
  16. data/lib/cucumber.rb +2 -1
  17. data/lib/cucumber/ast/step.rb +1 -1
  18. data/lib/cucumber/ast/step_invocation.rb +2 -15
  19. data/lib/cucumber/ast/table.rb +16 -6
  20. data/lib/cucumber/ast/tree_walker.rb +5 -5
  21. data/lib/cucumber/cli/options.rb +5 -8
  22. data/lib/cucumber/formatter/ansicolor.rb +7 -12
  23. data/lib/cucumber/formatter/cucumber.css +7 -1
  24. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +1 -1
  25. data/lib/cucumber/formatter/html.rb +5 -5
  26. data/lib/cucumber/formatter/interceptor.rb +62 -0
  27. data/lib/cucumber/formatter/junit.rb +30 -14
  28. data/lib/cucumber/formatter/pretty.rb +3 -3
  29. data/lib/cucumber/formatter/progress.rb +1 -1
  30. data/lib/cucumber/formatter/rerun.rb +1 -1
  31. data/lib/cucumber/formatter/usage.rb +1 -1
  32. data/lib/cucumber/js_support/js_snippets.rb +1 -1
  33. data/lib/cucumber/platform.rb +1 -1
  34. data/lib/cucumber/rb_support/rb_dsl.rb +15 -8
  35. data/lib/cucumber/rb_support/rb_language.rb +3 -3
  36. data/lib/cucumber/rb_support/rb_step_definition.rb +17 -5
  37. data/lib/cucumber/term/ansicolor.rb +118 -0
  38. data/spec/cucumber/ast/table_spec.rb +9 -0
  39. data/spec/cucumber/cli/configuration_spec.rb +12 -6
  40. data/spec/cucumber/cli/options_spec.rb +9 -3
  41. data/spec/cucumber/constantize_spec.rb +5 -1
  42. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
  43. data/spec/cucumber/formatter/interceptor_spec.rb +111 -0
  44. data/spec/cucumber/formatter/junit_spec.rb +36 -20
  45. data/spec/cucumber/formatter/progress_spec.rb +2 -2
  46. data/spec/cucumber/rb_support/rb_language_spec.rb +5 -5
  47. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +17 -1
  48. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +6 -2
  49. data/spec/cucumber/step_match_spec.rb +8 -4
  50. data/spec/spec_helper.rb +15 -1
  51. metadata +215 -82
  52. data/.gitmodules +0 -3
  53. data/lib/cucumber/formatter/pdf.rb +0 -244
@@ -0,0 +1,36 @@
1
+ Feature: Backtraces
2
+ In order to discover errors quickly
3
+ As a cuker
4
+ I want to see backtraces for failures
5
+
6
+ Background:
7
+ Given a file named "features/failing_hard.feature" with:
8
+ """
9
+ Feature: Sample
10
+ Scenario: Example
11
+ Given failing
12
+ """
13
+
14
+ @jruby
15
+ Scenario: Backtraces enabled
16
+ Given a file named "features/step_definitions/steps.rb" with:
17
+ """
18
+ require 'java'
19
+ java_import 'java.util.Collections'
20
+
21
+ Given /^failing$/ do
22
+ Collections.empty_list.add 1
23
+ end
24
+ """
25
+ When I run `cucumber features/failing_hard.feature`
26
+ Then it should fail with:
27
+ """
28
+ Feature: Sample
29
+
30
+ Scenario: Example # features/failing_hard.feature:2
31
+ Given failing # features/step_definitions/steps.rb:4
32
+ java.lang.UnsupportedOperationException: null (NativeException)
33
+ java/util/AbstractList.java:131:in `add'
34
+ java/util/AbstractList.java:91:in `add'
35
+ """
36
+
@@ -1,5 +1,5 @@
1
- @spork @my_issues
2
- Feature: DRb Server Integration: Regression test for Issue #117
1
+ @drb
2
+ Feature: DRb Server Integration
3
3
  To prevent waiting for Rails and other large Ruby applications to load their environments
4
4
  for each feature run Cucumber ships with a DRb client that can speak to a server which
5
5
  loads up the environment only once.
@@ -60,4 +60,4 @@ Feature: DRb Server Integration: Regression test for Issue #117
60
60
  And it should pass with:
61
61
  """
62
62
  1 step (1 passed)
63
- """
63
+ """
@@ -0,0 +1,46 @@
1
+ Feature: Formatter API: Step file path and line number (Issue #179)
2
+ To all reporter to understand location of current executing step let's fetch this information
3
+ from step/step_invocation and pass to reporters
4
+
5
+ Scenario: my own formatter
6
+ Given a file named "features/f.feature" with:
7
+ """
8
+ Feature: I'll use my own
9
+ because I'm worth it
10
+ Scenario: just print step current line and feature file name
11
+ Given step at line 4
12
+ Given step at line 5
13
+ """
14
+ And a file named "features/step_definitions/steps.rb" with:
15
+ """
16
+ Given /^step at line (.*)$/ do |line|
17
+ end
18
+ """
19
+ And a file named "features/support/jb/formatter.rb" with:
20
+ """
21
+ module Jb
22
+ class Formatter
23
+ def initialize(step_mother, io, options)
24
+ @step_mother = step_mother
25
+ @io = io
26
+ end
27
+
28
+ def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
29
+ @io.puts "step result event: #{file_colon_line}"
30
+ end
31
+
32
+ def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
33
+ @io.puts "step name event: #{file_colon_line}"
34
+ end
35
+ end
36
+ end
37
+ """
38
+ When I run cucumber "features/f.feature --format Jb::Formatter"
39
+ Then it should pass with exactly:
40
+ """
41
+ step result event: features/f.feature:4
42
+ step name event: features/f.feature:4
43
+ step result event: features/f.feature:5
44
+ step name event: features/f.feature:5
45
+
46
+ """
@@ -1,5 +1,5 @@
1
- Feature: Rerun formatter: Test for Issue #57
2
- details see https://github.com/cucumber/cucumber/issues/57
1
+ Feature: Rerun formatter
2
+ For details see https://github.com/cucumber/cucumber/issues/57
3
3
 
4
4
  Background:
5
5
  Given a file named "features/one_passing_one_failing.feature" with:
@@ -0,0 +1,47 @@
1
+ Feature: Run specific scenarios
2
+
3
+ You can choose to run a specific scenario using the file:line format
4
+
5
+ Background:
6
+ Given a file named "features/step_definitions/steps.rb" with:
7
+ """
8
+ Given(/pass/) {}
9
+ Given(/fail/) { raise "Failed" }
10
+ """
11
+
12
+ Scenario: Two scenarios, run just one of them
13
+ Given a file named "features/test.feature" with:
14
+ """
15
+ Feature:
16
+ Scenario:
17
+ Given this is undefined
18
+
19
+ Scenario: Hit
20
+ Given this passes
21
+ """
22
+ When I run `cucumber features/test.feature:5 -f progress`
23
+ Then it should pass with:
24
+ """
25
+ 1 scenario (1 passed)
26
+ """
27
+
28
+ Scenario: Single example from a scenario outline
29
+ Given a file named "features/test.feature" with:
30
+ """
31
+ Feature:
32
+ Scenario Outline:
33
+ Given this <something>
34
+
35
+ Examples:
36
+ | something |
37
+ | is undefined |
38
+ | fails |
39
+
40
+ Scenario: Miss
41
+ Given this passes
42
+ """
43
+ When I run `cucumber features/test.feature:8 -f progress`
44
+ Then it should fail with:
45
+ """
46
+ 1 scenario (1 failed)
47
+ """
@@ -1,21 +1,28 @@
1
1
  require 'cucumber/rake/task'
2
2
  require 'cucumber/platform'
3
3
 
4
+ class Cucumber::Rake::Task
5
+ def set_profile_for_current_ruby
6
+ self.profile = if(Cucumber::JRUBY)
7
+ Cucumber::WINDOWS ? 'jruby_win' : 'jruby'
8
+ elsif(Cucumber::WINDOWS_MRI)
9
+ 'windows_mri'
10
+ elsif(Cucumber::RUBY_1_9)
11
+ 'ruby_1_9'
12
+ end
13
+ end
14
+ end
15
+
4
16
  Cucumber::Rake::Task.new(:features) do |t|
5
17
  t.fork = false
18
+ t.set_profile_for_current_ruby
6
19
  end
7
20
 
8
21
  Cucumber::Rake::Task.new(:legacy_features) do |t|
9
22
  t.fork = false
10
23
  t.cucumber_opts = %w{legacy_features}
11
- if(Cucumber::JRUBY)
12
- t.profile = Cucumber::WINDOWS ? 'jruby_win' : 'jruby'
13
- elsif(Cucumber::WINDOWS_MRI)
14
- t.profile = 'windows_mri'
15
- elsif(Cucumber::RUBY_1_9)
16
- t.profile = 'ruby_1_9'
17
- end
24
+ t.set_profile_for_current_ruby
18
25
  t.rcov = ENV['RCOV']
19
26
  end
20
27
 
21
- task :cucumber => [:features, :legacy_features]
28
+ task :cucumber => [:features, :legacy_features]
@@ -551,13 +551,6 @@ Feature: Cucumber command line
551
551
 
552
552
  """
553
553
 
554
- # Fails on 1.9 because of encoding issues.
555
- @fails_on_1_9
556
- Scenario: Generate PDF with pdf formatter
557
- When I run cucumber --format pdf --out tmp/sample.pdf --dry-run features/sample.feature
558
- Then STDERR should be empty
559
- Then "fixtures/self_test/tmp/sample.pdf" should match "Pages 2"
560
-
561
554
  Scenario: Run feature elements which match a name using -n
562
555
  When I run cucumber -n Pisang -q features/
563
556
  Then STDERR should be empty
@@ -16,9 +16,11 @@ Feature: JUnit output formatter
16
16
  """
17
17
  <?xml version="1.0" encoding="UTF-8"?>
18
18
  <testsuite errors="0" failures="1" name="One passing scenario, one failing scenario" skipped="0" tests="2" time="0.005">
19
- <testcase classname="One passing scenario, one failing scenario.Passing" name="Passing" time="0.005">
19
+ <testcase classname="One passing scenario, one failing scenario" name="Passing" time="0.005">
20
+ <system-out/>
21
+ <system-err/>
20
22
  </testcase>
21
- <testcase classname="One passing scenario, one failing scenario.Failing" name="Failing" time="0.005">
23
+ <testcase classname="One passing scenario, one failing scenario" name="Failing" time="0.005">
22
24
  <failure message="failed Failing" type="failed">
23
25
  <![CDATA[Scenario: Failing
24
26
 
@@ -29,7 +31,15 @@ Feature: JUnit output formatter
29
31
  <![CDATA[ (RuntimeError)
30
32
  features/one_passing_one_failing.feature:7:in `Given a failing scenario']]>
31
33
  </failure>
34
+ <system-out/>
35
+ <system-err/>
32
36
  </testcase>
37
+ <system-out>
38
+ <![CDATA[]]>
39
+ </system-out>
40
+ <system-err>
41
+ <![CDATA[]]>
42
+ </system-err>
33
43
  </testsuite>
34
44
 
35
45
  """
@@ -44,9 +54,11 @@ Feature: JUnit output formatter
44
54
  """
45
55
  <?xml version="1.0" encoding="UTF-8"?>
46
56
  <testsuite errors="0" failures="1" name="Subdirectory - One passing scenario, one failing scenario" skipped="0" tests="2" time="0.005">
47
- <testcase classname="Subdirectory - One passing scenario, one failing scenario.Passing" name="Passing" time="0.005">
57
+ <testcase classname="Subdirectory - One passing scenario, one failing scenario" name="Passing" time="0.005">
58
+ <system-out/>
59
+ <system-err/>
48
60
  </testcase>
49
- <testcase classname="Subdirectory - One passing scenario, one failing scenario.Failing" name="Failing" time="0.005">
61
+ <testcase classname="Subdirectory - One passing scenario, one failing scenario" name="Failing" time="0.005">
50
62
  <failure message="failed Failing" type="failed">
51
63
  <![CDATA[Scenario: Failing
52
64
 
@@ -57,7 +69,15 @@ Feature: JUnit output formatter
57
69
  <![CDATA[ (RuntimeError)
58
70
  features/some_subdirectory/one_passing_one_failing.feature:7:in `Given a failing scenario']]>
59
71
  </failure>
72
+ <system-out/>
73
+ <system-err/>
60
74
  </testcase>
75
+ <system-out>
76
+ <![CDATA[]]>
77
+ </system-out>
78
+ <system-err>
79
+ <![CDATA[]]>
80
+ </system-err>
61
81
  </testsuite>
62
82
 
63
83
  """
@@ -72,12 +92,22 @@ Feature: JUnit output formatter
72
92
  """
73
93
  <?xml version="1.0" encoding="UTF-8"?>
74
94
  <testsuite errors="0" failures="0" name="Pending step" skipped="2" tests="2" time="0.009">
75
- <testcase classname="Pending step.Pending" name="Pending" time="0.009">
95
+ <testcase classname="Pending step" name="Pending" time="0.009">
76
96
  <skipped/>
97
+ <system-out/>
98
+ <system-err/>
77
99
  </testcase>
78
- <testcase classname="Pending step.Undefined" name="Undefined" time="0.009">
100
+ <testcase classname="Pending step" name="Undefined" time="0.009">
79
101
  <skipped/>
102
+ <system-out/>
103
+ <system-err/>
80
104
  </testcase>
105
+ <system-out>
106
+ <![CDATA[]]>
107
+ </system-out>
108
+ <system-err>
109
+ <![CDATA[]]>
110
+ </system-err>
81
111
  </testsuite>
82
112
 
83
113
  """
@@ -92,7 +122,7 @@ Feature: JUnit output formatter
92
122
  """
93
123
  <?xml version="1.0" encoding="UTF-8"?>
94
124
  <testsuite errors="0" failures="2" name="Pending step" skipped="0" tests="2" time="0.000160">
95
- <testcase classname="Pending step.Pending" name="Pending" time="0.000160">
125
+ <testcase classname="Pending step" name="Pending" time="0.000160">
96
126
  <failure message="pending Pending" type="pending">
97
127
  <![CDATA[Scenario: Pending
98
128
 
@@ -100,8 +130,10 @@ Feature: JUnit output formatter
100
130
  <![CDATA[TODO (Cucumber::Pending)
101
131
  features/pending.feature:4:in `Given a pending step']]>
102
132
  </failure>
133
+ <system-out/>
134
+ <system-err/>
103
135
  </testcase>
104
- <testcase classname="Pending step.Undefined" name="Undefined" time="0.000160">
136
+ <testcase classname="Pending step" name="Undefined" time="0.000160">
105
137
  <failure message="undefined Undefined" type="undefined">
106
138
  <![CDATA[Scenario: Undefined
107
139
 
@@ -109,7 +141,15 @@ Feature: JUnit output formatter
109
141
  <![CDATA[Undefined step: "an undefined step" (Cucumber::Undefined)
110
142
  features/pending.feature:7:in `Given an undefined step']]>
111
143
  </failure>
144
+ <system-out/>
145
+ <system-err/>
112
146
  </testcase>
147
+ <system-out>
148
+ <![CDATA[]]>
149
+ </system-out>
150
+ <system-err>
151
+ <![CDATA[]]>
152
+ </system-err>
113
153
  </testsuite>
114
154
 
115
155
  """
@@ -144,9 +184,11 @@ You \*must\* specify \-\-out DIR for the junit formatter
144
184
  """
145
185
  <?xml version="1.0" encoding="UTF-8"?>
146
186
  <testsuite errors="0" failures="1" name="Scenario outlines" skipped="0" tests="2" time="0.005">
147
- <testcase classname="Scenario outlines.Using scenario outlines" name="Using scenario outlines (outline example : | passing |)" time="0.005">
187
+ <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | passing |)" time="0.005">
188
+ <system-out/>
189
+ <system-err/>
148
190
  </testcase>
149
- <testcase classname="Scenario outlines.Using scenario outlines" name="Using scenario outlines (outline example : | failing |)" time="0.005">
191
+ <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | failing |)" time="0.005">
150
192
  <failure message="failed Using scenario outlines (outline example : | failing |)" type="failed">
151
193
  <![CDATA[Scenario Outline: Using scenario outlines
152
194
 
@@ -157,7 +199,15 @@ You \*must\* specify \-\-out DIR for the junit formatter
157
199
  <![CDATA[ (RuntimeError)
158
200
  features/scenario_outline.feature:4:in `Given a <type> scenario']]>
159
201
  </failure>
202
+ <system-out/>
203
+ <system-err/>
160
204
  </testcase>
205
+ <system-out>
206
+ <![CDATA[]]>
207
+ </system-out>
208
+ <system-err>
209
+ <![CDATA[]]>
210
+ </system-err>
161
211
  </testsuite>
162
212
 
163
213
  """
@@ -31,6 +31,7 @@ Feature: Language help
31
31
  """
32
32
  | ar | Arabic | العربية |
33
33
  | bg | Bulgarian | български |
34
+ | bm | Malay | Bahasa Melayu |
34
35
  | ca | Catalan | català |
35
36
  | cs | Czech | Česky |
36
37
  | cy-GB | Welsh | Cymraeg |
@@ -8,6 +8,7 @@ require 'cucumber/step_mother'
8
8
  require 'cucumber/cli/main'
9
9
  require 'cucumber/broadcaster'
10
10
  require 'cucumber/step_definitions'
11
+ require 'cucumber/term/ansicolor'
11
12
 
12
13
  module Cucumber
13
14
  class << self
@@ -24,4 +25,4 @@ module Cucumber
24
25
  @log = logger
25
26
  end
26
27
  end
27
- end
28
+ end
@@ -50,7 +50,7 @@ module Cucumber
50
50
  end
51
51
 
52
52
  def visit_step_result(visitor, step_match, multiline_arg, status, exception, background)
53
- visitor.visit_step_result(@keyword, step_match, @multiline_arg, status, exception, source_indent, background)
53
+ visitor.visit_step_result(@keyword, step_match, @multiline_arg, status, exception, source_indent, background, file_colon_line)
54
54
  end
55
55
 
56
56
  def first_match(visitor)
@@ -47,7 +47,8 @@ module Cucumber
47
47
  @status,
48
48
  @reported_exception,
49
49
  source_indent,
50
- @background
50
+ @background,
51
+ file_colon_line
51
52
  )
52
53
  end
53
54
 
@@ -93,20 +94,6 @@ module Cucumber
93
94
  end
94
95
 
95
96
  def failed(configuration, e, clear_backtrace)
96
- if Cucumber::JRUBY && e.class.name == 'NativeException'
97
- # JRuby's NativeException ignores #set_backtrace.
98
- # We're fixing it.
99
- e.instance_eval do
100
- def set_backtrace(backtrace)
101
- @backtrace = backtrace
102
- end
103
-
104
- def backtrace
105
- @backtrace
106
- end
107
- end
108
- end
109
-
110
97
  e.set_backtrace([]) if e.backtrace.nil? || clear_backtrace
111
98
  e.backtrace << @step.backtrace_line unless @step.backtrace_line.nil?
112
99
  e = filter_backtrace(e)
@@ -285,7 +285,8 @@ module Cucumber
285
285
  # #diff!. You can use #map_column! on either of the tables.
286
286
  #
287
287
  # A Different error is raised if there are missing rows or columns, or
288
- # surplus rows. An error is <em>not</em> raised for surplus columns.
288
+ # surplus rows. An error is <em>not</em> raised for surplus columns. An
289
+ # error is <em>not</em> raised for misplaced (out of sequence) columns.
289
290
  # Whether to raise or not raise can be changed by setting values in
290
291
  # +options+ to true or false:
291
292
  #
@@ -293,6 +294,7 @@ module Cucumber
293
294
  # * <tt>surplus_row</tt> : Raise on surplus rows (defaults to true)
294
295
  # * <tt>missing_col</tt> : Raise on missing columns (defaults to true)
295
296
  # * <tt>surplus_col</tt> : Raise on surplus columns (defaults to false)
297
+ # * <tt>misplaced_col</tt> : Raise on misplaced columns (defaults to false)
296
298
  #
297
299
  # The +other_table+ argument can be another Table, an Array of Array or
298
300
  # an Array of Hash (similar to the structure returned by #hashes).
@@ -301,7 +303,13 @@ module Cucumber
301
303
  # a Table argument, if you want to compare that table to some actual values.
302
304
  #
303
305
  def diff!(other_table, options={})
304
- options = {:missing_row => true, :surplus_row => true, :missing_col => true, :surplus_col => false}.merge(options)
306
+ options = {
307
+ :missing_row => true,
308
+ :surplus_row => true,
309
+ :missing_col => true,
310
+ :surplus_col => false,
311
+ :misplaced_col => false
312
+ }.merge(options)
305
313
 
306
314
  other_table = ensure_table(other_table)
307
315
  other_table.convert_headers!
@@ -317,6 +325,7 @@ module Cucumber
317
325
 
318
326
  missing_col = cell_matrix[0].detect{|cell| cell.status == :undefined}
319
327
  surplus_col = padded_width > original_width
328
+ misplaced_col = cell_matrix[0] != other_table.cell_matrix[0]
320
329
 
321
330
  require_diff_lcs
322
331
  cell_matrix.extend(Diff::LCS)
@@ -365,7 +374,8 @@ module Cucumber
365
374
  missing_row_pos && options[:missing_row] ||
366
375
  insert_row_pos && options[:surplus_row] ||
367
376
  missing_col && options[:missing_col] ||
368
- surplus_col && options[:surplus_col]
377
+ surplus_col && options[:surplus_col] ||
378
+ misplaced_col && options[:misplaced_col]
369
379
  raise Different.new(self) if should_raise
370
380
  end
371
381
 
@@ -437,13 +447,13 @@ module Cucumber
437
447
  options = {:color => true, :indent => 2, :prefixes => TO_S_PREFIXES}.merge(options)
438
448
  io = StringIO.new
439
449
 
440
- c = Term::ANSIColor.coloring?
441
- Term::ANSIColor.coloring = options[:color]
450
+ c = Cucumber::Term::ANSIColor.coloring?
451
+ Cucumber::Term::ANSIColor.coloring = options[:color]
442
452
  formatter = Formatter::Pretty.new(nil, io, options)
443
453
  formatter.instance_variable_set('@indent', options[:indent])
444
454
  TreeWalker.new(nil, [formatter]).visit_multiline_arg(self)
445
455
 
446
- Term::ANSIColor.coloring = c
456
+ Cucumber::Term::ANSIColor.coloring = c
447
457
  io.rewind
448
458
  s = "\n" + io.read + (" " * (options[:indent] - 2))
449
459
  s