cucumber 0.3.96 → 0.3.97

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 (93) hide show
  1. data/History.txt +22 -3
  2. data/License.txt +2 -0
  3. data/Manifest.txt +9 -5
  4. data/config/hoe.rb +1 -0
  5. data/examples/i18n/Rakefile +5 -3
  6. data/examples/i18n/fi/features/yhteenlasku.feature +5 -4
  7. data/examples/python/features/step_definitions/fib_steps.py +3 -0
  8. data/examples/python/features/support/env.rb +21 -21
  9. data/gem_tasks/contributors.rake +8 -0
  10. data/gem_tasks/features.rake +1 -0
  11. data/gem_tasks/sdoc.rake +7 -0
  12. data/lib/README.rdoc +12 -0
  13. data/lib/cucumber/ast/background.rb +1 -1
  14. data/lib/cucumber/ast/comment.rb +1 -1
  15. data/lib/cucumber/ast/examples.rb +9 -4
  16. data/lib/cucumber/ast/feature.rb +1 -1
  17. data/lib/cucumber/ast/feature_element.rb +1 -1
  18. data/lib/cucumber/ast/features.rb +1 -1
  19. data/lib/cucumber/ast/outline_table.rb +2 -2
  20. data/lib/cucumber/ast/py_string.rb +1 -1
  21. data/lib/cucumber/ast/scenario.rb +1 -1
  22. data/lib/cucumber/ast/scenario_outline.rb +8 -7
  23. data/lib/cucumber/ast/step.rb +1 -1
  24. data/lib/cucumber/ast/step_collection.rb +1 -1
  25. data/lib/cucumber/ast/step_invocation.rb +1 -1
  26. data/lib/cucumber/ast/table.rb +65 -45
  27. data/lib/cucumber/ast/tags.rb +2 -2
  28. data/lib/cucumber/ast/visitor.rb +6 -8
  29. data/lib/cucumber/broadcaster.rb +1 -1
  30. data/lib/cucumber/cli/language_help_formatter.rb +1 -1
  31. data/lib/cucumber/cli/main.rb +15 -52
  32. data/lib/cucumber/constantize.rb +1 -1
  33. data/lib/cucumber/core_ext/exception.rb +1 -1
  34. data/lib/cucumber/core_ext/instance_exec.rb +8 -3
  35. data/lib/cucumber/core_ext/proc.rb +1 -1
  36. data/lib/cucumber/core_ext/string.rb +1 -1
  37. data/lib/cucumber/feature_file.rb +4 -3
  38. data/lib/cucumber/filter.rb +2 -1
  39. data/lib/cucumber/formatter/ansicolor.rb +6 -5
  40. data/lib/cucumber/formatter/color_io.rb +2 -2
  41. data/lib/cucumber/formatter/console.rb +2 -0
  42. data/lib/cucumber/formatter/duration.rb +3 -0
  43. data/lib/cucumber/formatter/html.rb +1 -0
  44. data/lib/cucumber/formatter/junit.rb +1 -0
  45. data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
  46. data/lib/cucumber/formatter/pretty.rb +18 -4
  47. data/lib/cucumber/formatter/profile.rb +1 -0
  48. data/lib/cucumber/formatter/progress.rb +1 -0
  49. data/lib/cucumber/formatter/rerun.rb +2 -0
  50. data/lib/cucumber/formatter/steps.rb +1 -0
  51. data/lib/cucumber/formatter/tag_cloud.rb +2 -1
  52. data/lib/cucumber/formatter/unicode.rb +1 -1
  53. data/lib/cucumber/formatter/usage.rb +1 -0
  54. data/lib/cucumber/language_support.rb +30 -0
  55. data/lib/cucumber/language_support/language_methods.rb +34 -12
  56. data/lib/cucumber/parser/feature.rb +81 -57
  57. data/lib/cucumber/parser/feature.tt +3 -3
  58. data/lib/cucumber/parser/natural_language.rb +1 -1
  59. data/lib/cucumber/parser/table.rb +3 -0
  60. data/lib/cucumber/parser/treetop_ext.rb +6 -5
  61. data/lib/cucumber/platform.rb +1 -2
  62. data/lib/cucumber/py_support/py_dsl.py +8 -0
  63. data/lib/cucumber/py_support/py_language.py +2 -0
  64. data/lib/cucumber/py_support/py_language.rb +68 -0
  65. data/lib/cucumber/rails/world.rb +2 -1
  66. data/lib/cucumber/rake/task.rb +13 -11
  67. data/lib/cucumber/rb_support/rb_dsl.rb +27 -15
  68. data/lib/cucumber/rb_support/rb_hook.rb +1 -2
  69. data/lib/cucumber/rb_support/rb_language.rb +57 -33
  70. data/lib/cucumber/rb_support/rb_step_definition.rb +42 -38
  71. data/lib/cucumber/rb_support/rb_world.rb +93 -0
  72. data/lib/cucumber/rspec_neuter.rb +3 -3
  73. data/lib/cucumber/step_match.rb +2 -2
  74. data/lib/cucumber/step_mother.rb +91 -65
  75. data/lib/cucumber/version.rb +1 -1
  76. data/lib/cucumber/webrat/element_locator.rb +3 -3
  77. data/rails_generators/cucumber/templates/cucumber.rake +2 -0
  78. data/rails_generators/cucumber/templates/webrat_steps.rb +4 -0
  79. data/spec/cucumber/ast/background_spec.rb +8 -1
  80. data/spec/cucumber/ast/scenario_outline_spec.rb +1 -0
  81. data/spec/cucumber/ast/table_spec.rb +10 -0
  82. data/spec/cucumber/cli/options_spec.rb +1 -1
  83. data/spec/cucumber/parser/feature_parser_spec.rb +4 -0
  84. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +114 -0
  85. data/spec/cucumber/step_mother_spec.rb +29 -10
  86. data/spec/cucumber/treetop_parser/with_comments.feature +14 -1
  87. data/spec/cucumber/world/pending_spec.rb +1 -1
  88. metadata +21 -7
  89. data/gem_tasks/yard.rake +0 -8
  90. data/lib/cucumber/language_support/hook_methods.rb +0 -9
  91. data/lib/cucumber/world.rb +0 -89
  92. data/spec/cucumber/ast/visitor_spec.rb +0 -27
  93. data/spec/cucumber/step_definition_spec.rb +0 -102
@@ -1,8 +0,0 @@
1
- begin
2
- require 'yard'
3
-
4
- YARD::Rake::YardocTask.new do |t|
5
- t.files = ['lib/**/*.rb']
6
- end
7
- rescue LoadError => ignore
8
- end
@@ -1,9 +0,0 @@
1
- module Cucumber
2
- module LanguageSupport
3
- module HookMethods
4
- def matches_tag_names?(other_tag_names)
5
- tag_names.empty? || (tag_names.map{|tag| Ast::Tags.strip_prefix(tag)} & other_tag_names).any?
6
- end
7
- end
8
- end
9
- end
@@ -1,89 +0,0 @@
1
- module Cucumber
2
- # All steps are run in the context of an object that extends this module
3
- module World
4
- class << self
5
- def alias_adverb(adverb)
6
- alias_method adverb, :__cucumber_invoke
7
- end
8
- end
9
-
10
- attr_writer :__cucumber_step_mother
11
-
12
- # Call a step from within a step definition
13
- def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
14
- begin
15
- step_match = @__cucumber_step_mother.step_match(name)
16
- step_match.invoke(multiline_argument)
17
- rescue Exception => e
18
- e.nested! if Undefined === e
19
- raise e
20
- end
21
- end
22
-
23
- # Returns a Cucumber::Ast::Table for +text_or_table+, which can either
24
- # be a String:
25
- #
26
- # table(%{
27
- # | account | description | amount |
28
- # | INT-100 | Taxi | 114 |
29
- # | CUC-101 | Peeler | 22 |
30
- # })
31
- #
32
- # or a 2D Array:
33
- #
34
- # table([
35
- # %w{ account description amount },
36
- # %w{ INT-100 Taxi 114 },
37
- # %w{ CUC-101 Peeler 22 }
38
- # ])
39
- #
40
- def table(text_or_table, file=nil, line_offset=0)
41
- if Array === text_or_table
42
- Ast::Table.new(text_or_table)
43
- else
44
- @table_parser ||= Parser::TableParser.new
45
- @table_parser.parse_or_fail(text_or_table.strip, file, line_offset)
46
- end
47
- end
48
-
49
- # Output +announcement+ alongside the formatted output.
50
- # This is an alternative to using Kernel#puts - it will display
51
- # nicer, and in all outputs (in case you use several formatters)
52
- #
53
- # Beware that the output will be printed *before* the corresponding
54
- # step. This is because the step itself will not be printed until
55
- # after it has run, so it can be coloured according to its status.
56
- def announce(announcement)
57
- @__cucumber_step_mother.announce(announcement)
58
- end
59
-
60
- def pending(message = "TODO")
61
- if block_given?
62
- begin
63
- yield
64
- rescue Exception => e
65
- raise Pending.new(message)
66
- end
67
- raise Pending.new("Expected pending '#{message}' to fail. No Error was raised. No longer pending?")
68
- else
69
- raise Pending.new(message)
70
- end
71
- end
72
-
73
- # The default implementation of Object#inspect recursively
74
- # traverses all instance variables and invokes inspect.
75
- # This can be time consuming if the object graph is large.
76
- #
77
- # This can cause unnecessary delays when certain exceptions
78
- # occur. For example, MRI internally invokes #inspect on an
79
- # object that raises a NoMethodError. (JRuby does not do this).
80
- #
81
- # A World object can have many references created by the user
82
- # or frameworks (Rails), so to avoid long waiting times on
83
- # such errors in World we define it to just return a simple String.
84
- #
85
- def inspect
86
- sprintf("#<%s:0x%x>", self.class, self.object_id)
87
- end
88
- end
89
- end
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
- require 'cucumber/step_mother'
3
- require 'cucumber/ast'
4
-
5
- module Cucumber
6
- module Ast
7
- describe Visitor do
8
-
9
- it "should support checking scenario name matches regexps" do
10
- visitor = Visitor.new(mock("step mother"))
11
- scenario = Scenario.new(background=nil,
12
- comment=Comment.new(""),
13
- tags=Tags.new(0, []),
14
- line=99,
15
- keyword="",
16
- name="test name",
17
- steps=[])
18
-
19
- visitor.options = {:name_regexps => [/name/]}
20
-
21
- visitor.matches_scenario_names?(scenario).should be_true
22
- end
23
-
24
- end
25
- end
26
- end
27
-
@@ -1,102 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- require 'cucumber/ast'
4
- require 'cucumber/step_mother'
5
- require 'cucumber/rb_support/rb_language'
6
-
7
- module Cucumber
8
- describe RbStepDefinition do
9
- before do
10
- @step_mother = StepMother.new
11
- @step_mother.load_natural_language('en')
12
- @rb = @step_mother.load_programming_language('rb')
13
- @dsl = Object.new
14
- @dsl.extend RbSupport::RbDsl
15
- @step_mother.begin_scenario
16
-
17
- $inside = nil
18
- end
19
-
20
- it "should allow calling of other steps" do
21
- @dsl.Given /Outside/ do
22
- Given "Inside"
23
- end
24
- @dsl.Given /Inside/ do
25
- $inside = true
26
- end
27
-
28
- @step_mother.step_match("Outside").invoke(nil)
29
- $inside.should == true
30
- end
31
-
32
- it "should allow calling of other steps with inline arg" do
33
- @dsl.Given /Outside/ do
34
- Given "Inside", Ast::Table.new([['inside']])
35
- end
36
- @dsl.Given /Inside/ do |table|
37
- $inside = table.raw[0][0]
38
- end
39
-
40
- @step_mother.step_match("Outside").invoke(nil)
41
- $inside.should == 'inside'
42
- end
43
-
44
- it "should raise Undefined when inside step is not defined" do
45
- @dsl.Given /Outside/ do
46
- Given 'Inside'
47
- end
48
-
49
- lambda do
50
- @step_mother.step_match('Outside').invoke(nil)
51
- end.should raise_error(Undefined, 'Undefined step: "Inside"')
52
- end
53
-
54
- it "should allow forced pending" do
55
- @dsl.Given /Outside/ do
56
- pending("Do me!")
57
- end
58
-
59
- lambda do
60
- @step_mother.step_match("Outside").invoke(nil)
61
- end.should raise_error(Pending, "Do me!")
62
- end
63
-
64
- it "should allow announce" do
65
- v = mock('visitor')
66
- v.should_receive(:announce).with('wasup')
67
- @step_mother.visitor = v
68
- @dsl.Given /Loud/ do
69
- announce 'wasup'
70
- end
71
- @step_mother.step_match("Loud").invoke(nil)
72
- end
73
-
74
- def unindented(s)
75
- s.split("\n")[1..-2].join("\n").indent(-8)
76
- end
77
-
78
- it "should recognise quotes in name and make according regexp" do
79
- @rb.snippet_text('Given', 'A "first" arg').should == unindented(%{
80
- Given /^A "([^\\"]*)" arg$/ do |arg1|
81
- pending
82
- end
83
- })
84
- end
85
-
86
- it "should recognise several quoted words in name and make according regexp and args" do
87
- @rb.snippet_text('Given', 'A "first" and "second" arg').should == unindented(%{
88
- Given /^A "([^\\"]*)" and "([^\\"]*)" arg$/ do |arg1, arg2|
89
- pending
90
- end
91
- })
92
- end
93
-
94
- it "should not use quote group when there are no quotes" do
95
- @rb.snippet_text('Given', 'A first arg').should == unindented(%{
96
- Given /^A first arg$/ do
97
- pending
98
- end
99
- })
100
- end
101
- end
102
- end