kosmas58-cucumber 0.1.99.23 → 0.1.100.5

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 (100) hide show
  1. data/History.txt +8 -23
  2. data/Manifest.txt +14 -2
  3. data/examples/i18n/en-lol/Rakefile +6 -0
  4. data/examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb +16 -0
  5. data/examples/i18n/en-lol/features/stuffing.feature +8 -0
  6. data/examples/i18n/en-lol/features/support/env.rb +8 -0
  7. data/examples/i18n/en-lol/lib/basket.rb +12 -0
  8. data/examples/i18n/en-lol/lib/belly.rb +11 -0
  9. data/examples/i18n/et/features/jagamine.feature +9 -0
  10. data/examples/jbehave/README.textile +4 -1
  11. data/examples/jbehave/features/trading.feature +4 -0
  12. data/examples/jbehave/pom.xml +5 -0
  13. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +6 -1
  14. data/examples/selenium/features/step_definitons/search_steps.rb +13 -0
  15. data/examples/selenium/features/support/env.rb +19 -0
  16. data/examples/selenium_webrat/Rakefile +6 -0
  17. data/examples/selenium_webrat/features/search.feature +9 -0
  18. data/examples/selenium_webrat/features/step_definitons/search_steps.rb +13 -0
  19. data/examples/selenium_webrat/features/support/env.rb +41 -0
  20. data/examples/self_test/Rakefile +1 -1
  21. data/examples/self_test/features/background/failing_background.feature +1 -0
  22. data/examples/self_test/features/step_definitions/sample_steps.rb +1 -1
  23. data/examples/self_test/features/support/tag_count_formatter.rb +1 -1
  24. data/examples/tickets/Rakefile +13 -8
  25. data/examples/tickets/cucumber.yml +2 -1
  26. data/examples/tickets/features/236.feature +13 -0
  27. data/examples/tickets/features/241.feature +13 -0
  28. data/examples/tickets/features/step_definitons/tickets_steps.rb +17 -4
  29. data/examples/tickets/features/tickets.feature +1 -1
  30. data/features/background.feature +9 -11
  31. data/features/cucumber_cli.feature +24 -1
  32. data/features/cucumber_cli_outlines.feature +10 -19
  33. data/features/report_called_undefined_steps.feature +2 -0
  34. data/gem_tasks/rspec.rake +3 -2
  35. data/lib/cucumber.rb +7 -15
  36. data/lib/cucumber/ast.rb +3 -3
  37. data/lib/cucumber/ast/background.rb +28 -66
  38. data/lib/cucumber/ast/examples.rb +15 -3
  39. data/lib/cucumber/ast/feature.rb +20 -24
  40. data/lib/cucumber/ast/feature_element.rb +46 -0
  41. data/lib/cucumber/ast/features.rb +2 -21
  42. data/lib/cucumber/ast/outline_table.rb +46 -14
  43. data/lib/cucumber/ast/py_string.rb +9 -3
  44. data/lib/cucumber/ast/scenario.rb +34 -73
  45. data/lib/cucumber/ast/scenario_outline.rb +40 -42
  46. data/lib/cucumber/ast/step.rb +51 -90
  47. data/lib/cucumber/ast/step_collection.rb +66 -0
  48. data/lib/cucumber/ast/step_invocation.rb +110 -0
  49. data/lib/cucumber/ast/table.rb +41 -21
  50. data/lib/cucumber/ast/tags.rb +4 -11
  51. data/lib/cucumber/ast/visitor.rb +35 -19
  52. data/lib/cucumber/broadcaster.rb +1 -3
  53. data/lib/cucumber/cli/configuration.rb +25 -17
  54. data/lib/cucumber/cli/language_help_formatter.rb +4 -4
  55. data/lib/cucumber/cli/main.rb +6 -4
  56. data/lib/cucumber/core_ext/proc.rb +2 -2
  57. data/lib/cucumber/formatter/ansicolor.rb +0 -1
  58. data/lib/cucumber/formatter/console.rb +24 -34
  59. data/lib/cucumber/formatter/html.rb +18 -11
  60. data/lib/cucumber/formatter/pretty.rb +48 -36
  61. data/lib/cucumber/formatter/profile.rb +6 -6
  62. data/lib/cucumber/formatter/progress.rb +14 -22
  63. data/lib/cucumber/formatter/rerun.rb +6 -6
  64. data/lib/cucumber/jbehave.rb +21 -26
  65. data/lib/cucumber/languages.yml +17 -2
  66. data/lib/cucumber/parser/feature.rb +26 -29
  67. data/lib/cucumber/parser/feature.tt +17 -12
  68. data/lib/cucumber/parser/treetop_ext.rb +13 -13
  69. data/lib/cucumber/platform.rb +0 -1
  70. data/lib/cucumber/rails/world.rb +2 -2
  71. data/lib/cucumber/rake/task.rb +1 -2
  72. data/lib/cucumber/step_definition.rb +21 -12
  73. data/lib/cucumber/step_match.rb +49 -0
  74. data/lib/cucumber/step_mother.rb +100 -80
  75. data/lib/cucumber/version.rb +2 -2
  76. data/lib/cucumber/world.rb +53 -0
  77. data/rails_generators/cucumber/templates/paths.rb +1 -1
  78. data/rails_generators/cucumber/templates/webrat_steps.rb +17 -17
  79. data/rails_generators/feature/feature_generator.rb +5 -1
  80. data/rails_generators/feature/templates/steps.erb +0 -4
  81. data/spec/cucumber/ast/background_spec.rb +32 -41
  82. data/spec/cucumber/ast/feature_factory.rb +10 -1
  83. data/spec/cucumber/ast/feature_spec.rb +7 -30
  84. data/spec/cucumber/ast/py_string_spec.rb +7 -0
  85. data/spec/cucumber/ast/scenario_outline_spec.rb +3 -0
  86. data/spec/cucumber/ast/scenario_spec.rb +8 -25
  87. data/spec/cucumber/ast/step_collection_spec.rb +8 -0
  88. data/spec/cucumber/ast/step_spec.rb +49 -28
  89. data/spec/cucumber/ast/table_spec.rb +13 -3
  90. data/spec/cucumber/ast/tags_spec.rb +2 -18
  91. data/spec/cucumber/broadcaster_spec.rb +6 -5
  92. data/spec/cucumber/cli/configuration_spec.rb +7 -0
  93. data/spec/cucumber/cli/main_spec.rb +1 -1
  94. data/spec/cucumber/parser/feature_parser_spec.rb +6 -5
  95. data/spec/cucumber/step_definition_spec.rb +16 -5
  96. data/spec/cucumber/step_mother_spec.rb +6 -6
  97. data/spec/cucumber/world/pending_spec.rb +1 -1
  98. metadata +24 -5
  99. data/lib/cucumber/ast/filter.rb +0 -22
  100. data/lib/cucumber/ast/steps.rb +0 -13
@@ -0,0 +1,13 @@
1
+ Users want to use cucumber, so tests are necessary to verify
2
+ it is all working as expected
3
+
4
+ Feature: Using the Console Formatter
5
+ In order to verify this error
6
+ I want to run this feature using the progress format
7
+ So that it can be fixed
8
+
9
+ Scenario: A normal feature
10
+ Given I have a pending step
11
+ When I run this feature with the progress format
12
+ Then I should get a no method error for 'backtrace_line'
13
+
@@ -5,9 +5,6 @@ World do
5
5
  end
6
6
 
7
7
  After do |scenario|
8
- if scenario.status.index(:failed)
9
- # Call the BDD police
10
- end
11
8
  end
12
9
 
13
10
  Given "be_empty" do
@@ -53,8 +50,24 @@ Then /^I should be (\w+) in (\w+)$/ do |key, value|
53
50
  hash[key].should == value
54
51
  end
55
52
 
56
- Then /^I shoule see a multiline string like$/ do |s|
53
+ Then /^I should see a multiline string like$/ do |s|
57
54
  s.should == %{A string
58
55
  that spans
59
56
  several lines}
60
57
  end
58
+
59
+ Given /^the following users exist in the system$/ do |table|
60
+ table.hashes[0][:role_assignments].should == 'HUMAN RESOURCE'
61
+ end
62
+
63
+ Given /^I have a pending step$/ do
64
+ pending
65
+ end
66
+
67
+ When /^I run this feature with the progress format$/ do
68
+ pending
69
+ end
70
+
71
+ Then /^I should get a no method error for 'backtrace_line'$/ do
72
+ pending
73
+ end
@@ -20,7 +20,7 @@ Feature: Cucumber
20
20
  | Oslo | London |
21
21
  Then I should be working in London
22
22
  And I should be born in Oslo
23
- And I shoule see a multiline string like
23
+ And I should see a multiline string like
24
24
  """
25
25
  A string
26
26
  that spans
@@ -16,7 +16,7 @@ Feature: backgrounds
16
16
  Then I should have '10' cukes
17
17
 
18
18
  1 scenario
19
- 2 passed steps
19
+ 3 passed steps
20
20
 
21
21
  """
22
22
 
@@ -64,7 +64,7 @@ Feature: backgrounds
64
64
  | 10 |
65
65
 
66
66
  2 scenarios
67
- 4 passed steps
67
+ 5 passed steps
68
68
 
69
69
  """
70
70
 
@@ -80,6 +80,7 @@ Feature: backgrounds
80
80
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
81
81
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
82
82
  features/background/failing_background.feature:4:in `Given failing without a table'
83
+ And '10' cukes
83
84
 
84
85
  Scenario: failing background
85
86
  Then I should have '10' cukes
@@ -88,8 +89,8 @@ Feature: backgrounds
88
89
  Then I should have '10' cukes
89
90
 
90
91
  2 scenarios
91
- 2 failed steps
92
- 2 skipped steps
92
+ 1 failed step
93
+ 5 skipped steps
93
94
 
94
95
  """
95
96
 
@@ -121,8 +122,8 @@ Feature: backgrounds
121
122
  | 10 |
122
123
 
123
124
  2 scenarios
124
- 2 failed steps
125
- 2 skipped steps
125
+ 1 failed step
126
+ 4 skipped steps
126
127
 
127
128
  """
128
129
 
@@ -160,15 +161,12 @@ Feature: backgrounds
160
161
  Scenario: passing background
161
162
  Then I should have '10' global cukes
162
163
 
163
- Background:
164
- Given passing without a table
164
+ Scenario: failing background
165
165
  And '10' global cukes
166
166
  FAIL (RuntimeError)
167
167
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
168
168
  ./features/step_definitions/sample_steps.rb:37:in `/^'(.+)' global cukes$/'
169
- features/background/failing_background_after_success.feature:3:in `And '10' global cukes'
170
-
171
- Scenario: failing background
169
+ features/background/failing_background_after_success.feature:5:in `And '10' global cukes'
172
170
  Then I should have '10' global cukes
173
171
 
174
172
  2 scenarios
@@ -32,7 +32,7 @@ Feature: Cucumber command line
32
32
  features/sample.feature:6:in `Given missing'
33
33
 
34
34
  1 scenario
35
- 1 failed step
35
+ 1 undefined step
36
36
 
37
37
  """
38
38
 
@@ -337,6 +337,29 @@ Feature: Cucumber command line
337
337
 
338
338
  """
339
339
 
340
+ Scenario: Run with a negative tag
341
+ When I run cucumber -q features/sample.feature --dry-run -t ~four
342
+ Then it should pass with
343
+ """
344
+ @one
345
+ Feature: Sample
346
+
347
+ @two @three
348
+ Scenario: Missing
349
+ Given missing
350
+
351
+ @three
352
+ Scenario: Passing
353
+ Given passing
354
+ | a | b |
355
+ | c | d |
356
+
357
+ 2 scenarios
358
+ 1 skipped step
359
+ 1 undefined step
360
+
361
+ """
362
+
340
363
  Scenario: Reformat files with --autoformat
341
364
  When I run cucumber --autoformat tmp/formatted features
342
365
  Then examples/self_test/tmp/formatted/features/sample.feature should contain
@@ -17,10 +17,10 @@ Feature: Cucumber command line
17
17
  | missing | passing |
18
18
  | passing | passing |
19
19
  | failing | passing |
20
- FAIL (RuntimeError)
21
- ./features/step_definitions/sample_steps.rb:2:in `flunker'
22
- ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
23
- features/outline_sample.feature:12:in `Given failing without a table'
20
+ FAIL (RuntimeError)
21
+ ./features/step_definitions/sample_steps.rb:2:in `flunker'
22
+ ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
23
+ features/outline_sample.feature:6:in `Given <state> without a table'
24
24
 
25
25
  Examples: Only passing
26
26
  | state | other_state |
@@ -34,8 +34,6 @@ Feature: Cucumber command line
34
34
 
35
35
  """
36
36
 
37
- # The "Only Passing" should not be printed
38
- @buggy
39
37
  Scenario: Run single failing scenario outline table row
40
38
  When I run cucumber features/outline_sample.feature:12
41
39
  Then it should fail with
@@ -49,13 +47,10 @@ Feature: Cucumber command line
49
47
  Examples: Rainbow colours
50
48
  | state | other_state |
51
49
  | failing | passing |
52
- FAIL (RuntimeError)
53
- ./features/step_definitions/sample_steps.rb:2:in `flunker'
54
- ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
55
- features/outline_sample.feature:12:in `Given failing without a table'
56
-
57
- Examples: Only passing
58
- | state | other_state |
50
+ FAIL (RuntimeError)
51
+ ./features/step_definitions/sample_steps.rb:2:in `flunker'
52
+ ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
53
+ features/outline_sample.feature:6:in `Given <state> without a table'
59
54
 
60
55
  1 scenario
61
56
  1 failed step
@@ -67,18 +62,14 @@ Feature: Cucumber command line
67
62
  When I run cucumber -q --format progress features/outline_sample.feature
68
63
  Then it should fail with
69
64
  """
70
- UUS..FS..
71
-
72
- (::) undefined scenarios (::)
73
-
74
- features/outline_sample.feature:3:in `Scenario: I have no steps'
65
+ ----U-..F---..
75
66
 
76
67
  (::) failed steps (::)
77
68
 
78
69
  FAIL (RuntimeError)
79
70
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
80
71
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
81
- features/outline_sample.feature:12:in `Given failing without a table'
72
+ features/outline_sample.feature:6:in `Given <state> without a table'
82
73
 
83
74
  5 scenarios
84
75
  1 failed step
@@ -12,11 +12,13 @@ Feature: Cucumber command line
12
12
  Given a step definition that calls an undefined step # features/step_definitions/sample_steps.rb:19
13
13
  Undefined step: "this does not exist" (Cucumber::Undefined)
14
14
  ./features/step_definitions/sample_steps.rb:20:in `/^a step definition that calls an undefined step$/'
15
+ features/call_undefined_step_from_step_def.feature:4:in `Given a step definition that calls an undefined step'
15
16
 
16
17
  Scenario: Call via another # features/call_undefined_step_from_step_def.feature:6
17
18
  Given call step "a step definition that calls an undefined step" # features/step_definitions/sample_steps.rb:23
18
19
  Undefined step: "this does not exist" (Cucumber::Undefined)
19
20
  ./features/step_definitions/sample_steps.rb:20:in `/^a step definition that calls an undefined step$/'
21
+ features/call_undefined_step_from_step_def.feature:7:in `Given call step "a step definition that calls an undefined step"'
20
22
 
21
23
  2 scenarios
22
24
  2 undefined steps
data/gem_tasks/rspec.rake CHANGED
@@ -32,7 +32,8 @@ if require_spec
32
32
  t.spec_opts = ['--options', "spec/spec.opts"]
33
33
  t.spec_files = FileList['spec/**/*_spec.rb']
34
34
  t.fail_on_error = false
35
- t.rcov = true
36
- t.rcov_opts = ['--exclude', 'spec']
35
+ #t.rcov = true
36
+ t.rcov = ENV['RCOV']
37
+ t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/}
37
38
  end
38
39
  end
data/lib/cucumber.rb CHANGED
@@ -44,24 +44,16 @@ module Cucumber
44
44
  alias_steps(keywords)
45
45
  end
46
46
 
47
- # Sets up additional aliases for Given, When and Then.
48
- # Try adding the following to your <tt>support/env.rb</tt>:
49
- #
50
- # # Given When Then in Norwegian
51
- # Cucumber.alias_steps %w{Gitt Naar Saa}
52
- #
53
- # You cannot use special characters here, because methods
54
- # with special characters is not valid Ruby code
47
+ # Sets up additional method aliases for Given, When and Then.
48
+ # This does *not* affect how feature files are parsed. If you
49
+ # want to create aliases in the parser, you have to do this in
50
+ # languages.yml. For example:
55
51
  #
52
+ # and: And|With
56
53
  def alias_steps(keywords)
57
54
  keywords.each do |adverb|
58
- StepMother.class_eval do
59
- alias_method adverb, :register_step_definition
60
- end
61
-
62
- StepMother::WorldMethods.class_eval do
63
- alias_method adverb, :__cucumber_invoke
64
- end
55
+ StepMother.alias_adverb(adverb)
56
+ World.alias_adverb(adverb)
65
57
  end
66
58
  end
67
59
  end
data/lib/cucumber/ast.rb CHANGED
@@ -2,17 +2,17 @@ require 'cucumber/ast/comment'
2
2
  require 'cucumber/ast/tags'
3
3
  require 'cucumber/ast/features'
4
4
  require 'cucumber/ast/feature'
5
+ require 'cucumber/ast/background'
5
6
  require 'cucumber/ast/scenario'
6
7
  require 'cucumber/ast/scenario_outline'
7
- require 'cucumber/ast/background'
8
- require 'cucumber/ast/steps'
8
+ require 'cucumber/ast/step_invocation'
9
+ require 'cucumber/ast/step_collection'
9
10
  require 'cucumber/ast/step'
10
11
  require 'cucumber/ast/table'
11
12
  require 'cucumber/ast/py_string'
12
13
  require 'cucumber/ast/outline_table'
13
14
  require 'cucumber/ast/examples'
14
15
  require 'cucumber/ast/visitor'
15
- require 'cucumber/ast/filter'
16
16
 
17
17
  module Cucumber
18
18
  # Classes in this module represent the Abstract Syntax Tree (AST)
@@ -1,88 +1,50 @@
1
+ require 'cucumber/ast/feature_element'
2
+
1
3
  module Cucumber
2
4
  module Ast
3
- class Background < Scenario
4
-
5
- attr_accessor :world
6
- attr_reader :status
5
+ class Background
6
+ include FeatureElement
7
+ attr_writer :feature
7
8
 
8
9
  def initialize(comment, line, keyword, steps)
9
- @record_executed_steps = true
10
- super(comment, Tags.new(1, []), line, keyword, "", steps)
10
+ @comment, @line, @keyword, @steps = comment, line, keyword, StepCollection.new(steps)
11
+ attach_steps(steps)
12
+ @step_invocations = @steps.step_invocations(true)
11
13
  end
12
14
 
13
- def accept(visitor)
14
- @world = visitor.new_world
15
- if already_visited_steps?
16
- @status = execute_steps(visitor)
15
+ def step_collection(step_invocations)
16
+ unless(@first_collection_created)
17
+ @first_collection_created = true
18
+ @step_invocations.dup(step_invocations)
17
19
  else
18
- @status = visit_background_and_steps(visitor, @steps)
19
- @steps_visited = true
20
+ @steps.step_invocations(true).dup(step_invocations)
20
21
  end
21
22
  end
22
23
 
23
- def step_executed(step)
24
- @feature.step_executed(step) if @feature && @record_executed_steps
24
+ def accept(visitor)
25
+ visitor.visit_comment(@comment)
26
+ visitor.visit_background_name(@keyword, "", file_colon_line(@line), source_indent(text_length))
27
+ visitor.step_mother.before_and_after(self)
28
+ visitor.visit_steps(@step_invocations)
29
+ @failed = @step_invocations.detect{|step_invocation| step_invocation.exception}
30
+ end
31
+
32
+ def failed?
33
+ @failed
25
34
  end
26
35
 
27
- def already_visited_steps?
28
- @steps_visited
36
+ def text_length
37
+ @keyword.jlength
29
38
  end
30
39
 
31
- def to_sexp #:nodoc:
40
+ def to_sexp
32
41
  sexp = [:background, @line, @keyword]
33
42
  comment = @comment.to_sexp
34
43
  sexp += [comment] if comment
35
- tags = @tags.to_sexp
36
- sexp += tags if tags.any?
37
- steps = @steps.map{|step| step.to_sexp}
44
+ steps = @steps.to_sexp
38
45
  sexp += steps if steps.any?
39
46
  sexp
40
47
  end
41
-
42
- private
43
-
44
- def visit_background_and_steps(visitor, steps)
45
- visitor.visit_comment(@comment)
46
- visitor.visit_scenario_name(@keyword, @name, file_line(@line), source_indent(text_length))
47
-
48
- previous = :passed
49
- steps.each do |step|
50
- step.previous = previous
51
- step.world = @world
52
- visitor.visit_step(step)
53
- previous = step.status
54
- end
55
- previous
56
- end
57
-
58
- def execute_steps(visitor)
59
- previous = :passed
60
- executed_steps = []
61
- exception = nil
62
- @steps.each do |step|
63
- executed_step, previous, _ = step.execute_as_new(@world, previous, visitor, @line)
64
- executed_steps << executed_step
65
- exception ||= executed_step.exception
66
- end
67
- @steps = executed_steps
68
-
69
- if exception && @status != :failed
70
- without_recording_steps do
71
- @steps_visited = false
72
- #Since the steps have already been executed they will not be re-run, they will just be displayed
73
- visitor.visit_background(self)
74
- end
75
- end
76
-
77
- previous
78
- end
79
-
80
- def without_recording_steps
81
- @record_executed_steps = false
82
- yield
83
- @record_executed_steps = true
84
- end
85
-
86
48
  end
87
49
  end
88
- end
50
+ end
@@ -10,12 +10,24 @@ module Cucumber
10
10
  visitor.visit_outline_table(@outline_table)
11
11
  end
12
12
 
13
+ def descend?(visitor)
14
+ @outline_table.descend?(visitor)
15
+ end
16
+
17
+ def skip_invoke!
18
+ @outline_table.skip_invoke!
19
+ end
20
+
21
+ def matches_scenario_names?(scenario_names)
22
+ scenario_names.detect{|name| name == @name}
23
+ end
24
+
13
25
  def each_example_row(&proc)
14
- @outline_table.each_cells_row(&proc)
26
+ @outline_table.cells_rows[1..-1].each(&proc)
15
27
  end
16
28
 
17
- def at_lines?(lines)
18
- lines.empty? || lines.index(@line) || @outline_table.at_lines?(lines)
29
+ def matches_lines?(lines)
30
+ lines.index(@line) || @outline_table.matches_lines?(lines)
19
31
  end
20
32
 
21
33
  def to_sexp