cucumber 0.3.95 → 0.3.96

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 (55) hide show
  1. data/History.txt +21 -0
  2. data/Manifest.txt +9 -3
  3. data/examples/sinatra/features/support/env.rb +1 -3
  4. data/features/cucumber_cli.feature +1 -0
  5. data/features/drb_server_integration.feature +56 -3
  6. data/features/junit_formatter.feature +23 -12
  7. data/features/step_definitions/cucumber_steps.rb +13 -2
  8. data/features/support/env.rb +19 -3
  9. data/lib/cucumber/ast/feature_element.rb +1 -1
  10. data/lib/cucumber/ast/step.rb +1 -1
  11. data/lib/cucumber/ast/step_invocation.rb +3 -2
  12. data/lib/cucumber/cli/configuration.rb +9 -25
  13. data/lib/cucumber/cli/drb_client.rb +7 -3
  14. data/lib/cucumber/cli/language_help_formatter.rb +4 -4
  15. data/lib/cucumber/cli/main.rb +26 -46
  16. data/lib/cucumber/cli/options.rb +3 -0
  17. data/lib/cucumber/constantize.rb +28 -0
  18. data/lib/cucumber/feature_file.rb +3 -3
  19. data/lib/cucumber/formatter/junit.rb +13 -9
  20. data/lib/cucumber/formatter/pretty.rb +2 -2
  21. data/lib/cucumber/language_support/hook_methods.rb +9 -0
  22. data/lib/cucumber/language_support/language_methods.rb +47 -0
  23. data/lib/cucumber/language_support/step_definition_methods.rb +44 -0
  24. data/lib/cucumber/parser/natural_language.rb +72 -0
  25. data/lib/cucumber/rb_support/rb_dsl.rb +73 -0
  26. data/lib/cucumber/rb_support/rb_hook.rb +19 -0
  27. data/lib/cucumber/rb_support/rb_language.rb +129 -0
  28. data/lib/cucumber/rb_support/rb_step_definition.rb +56 -0
  29. data/lib/cucumber/step_match.rb +2 -2
  30. data/lib/cucumber/step_mother.rb +87 -206
  31. data/lib/cucumber/version.rb +1 -1
  32. data/lib/cucumber/webrat/element_locator.rb +7 -7
  33. data/lib/cucumber/world.rb +28 -8
  34. data/rails_generators/cucumber/templates/cucumber_environment.rb +2 -2
  35. data/rails_generators/cucumber/templates/spork_env.rb +0 -2
  36. data/rails_generators/cucumber/templates/webrat_steps.rb +17 -0
  37. data/spec/cucumber/ast/background_spec.rb +8 -5
  38. data/spec/cucumber/ast/feature_factory.rb +4 -5
  39. data/spec/cucumber/ast/feature_spec.rb +7 -1
  40. data/spec/cucumber/ast/scenario_outline_spec.rb +10 -6
  41. data/spec/cucumber/ast/scenario_spec.rb +8 -3
  42. data/spec/cucumber/ast/step_collection_spec.rb +2 -2
  43. data/spec/cucumber/cli/configuration_spec.rb +15 -0
  44. data/spec/cucumber/cli/drb_client_spec.rb +35 -1
  45. data/spec/cucumber/cli/main_spec.rb +5 -4
  46. data/spec/cucumber/cli/options_spec.rb +6 -0
  47. data/spec/cucumber/parser/feature_parser_spec.rb +6 -5
  48. data/spec/cucumber/parser/table_parser_spec.rb +1 -1
  49. data/spec/cucumber/step_definition_spec.rb +26 -25
  50. data/spec/cucumber/step_mother_spec.rb +46 -41
  51. data/spec/cucumber/world/pending_spec.rb +4 -5
  52. metadata +11 -5
  53. data/lib/cucumber/cli/rb_step_def_loader.rb +0 -14
  54. data/lib/cucumber/parser/i18n/language.rb +0 -87
  55. data/lib/cucumber/step_definition.rb +0 -122
@@ -1,122 +0,0 @@
1
- require 'cucumber/step_match'
2
- require 'cucumber/core_ext/string'
3
- require 'cucumber/core_ext/proc'
4
-
5
- module Cucumber
6
- module StepDefinitionMethods
7
- def step_match(name_to_match, name_to_report)
8
- if(match = name_to_match.match(regexp))
9
- StepMatch.new(self, name_to_match, name_to_report, match.captures)
10
- else
11
- nil
12
- end
13
- end
14
-
15
- # Formats the matched arguments of the associated Step. This method
16
- # is usually called from visitors, which render output.
17
- #
18
- # The +format+ can either be a String or a Proc.
19
- #
20
- # If it is a String it should be a format string according to
21
- # <tt>Kernel#sprinf</tt>, for example:
22
- #
23
- # '<span class="param">%s</span></tt>'
24
- #
25
- # If it is a Proc, it should take one argument and return the formatted
26
- # argument, for example:
27
- #
28
- # lambda { |param| "[#{param}]" }
29
- #
30
- def format_args(step_name, format)
31
- step_name.gzub(regexp, format)
32
- end
33
-
34
- def match(step_name)
35
- case step_name
36
- when String then regexp.match(step_name)
37
- when Regexp then regexp == step_name
38
- end
39
- end
40
-
41
- def backtrace_line
42
- "#{file_colon_line}:in `#{regexp.inspect}'"
43
- end
44
-
45
- def text_length
46
- regexp.inspect.jlength
47
- end
48
- end
49
-
50
- # A Step Definition holds a Regexp and a Proc, and is created
51
- # by calling <tt>Given</tt>, <tt>When</tt> or <tt>Then</tt>
52
- # in the <tt>step_definitions</tt> ruby files - for example:
53
- #
54
- # Given /I have (\d+) cucumbers in my belly/ do
55
- # # some code here
56
- # end
57
- #
58
- class StepDefinition
59
- PARAM_PATTERN = /"([^\"]*)"/
60
- ESCAPED_PARAM_PATTERN = '"([^\\"]*)"'
61
-
62
- def self.snippet_text(step_keyword, step_name, multiline_arg_class = nil)
63
- escaped = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
64
- escaped = escaped.gsub(PARAM_PATTERN, ESCAPED_PARAM_PATTERN)
65
-
66
- n = 0
67
- block_args = escaped.scan(ESCAPED_PARAM_PATTERN).map do |a|
68
- n += 1
69
- "arg#{n}"
70
- end
71
- block_args << multiline_arg_class.default_arg_name unless multiline_arg_class.nil?
72
- block_arg_string = block_args.empty? ? "" : " |#{block_args.join(", ")}|"
73
- multiline_class_comment = ""
74
- if(multiline_arg_class == Ast::Table)
75
- multiline_class_comment = "# #{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n "
76
- end
77
-
78
- "#{step_keyword} /^#{escaped}$/ do#{block_arg_string}\n #{multiline_class_comment}pending\nend"
79
- end
80
-
81
- class MissingProc < StandardError
82
- def message
83
- "Step definitions must always have a proc"
84
- end
85
- end
86
-
87
- include StepDefinitionMethods
88
-
89
- attr_reader :proc
90
-
91
- def initialize(pattern, &proc)
92
- raise MissingProc if proc.nil?
93
- if String === pattern
94
- p = pattern.gsub(/\$\w+/, '(.*)') # Replace $var with (.*)
95
- pattern = Regexp.new("^#{p}$")
96
- end
97
- @regexp, @proc = pattern, proc
98
- end
99
-
100
- def regexp
101
- @regexp
102
- end
103
-
104
- def invoke(world, args)
105
- args = args.map{|arg| Ast::PyString === arg ? arg.to_s : arg}
106
- begin
107
- world.cucumber_instance_exec(true, regexp.inspect, *args, &@proc)
108
- rescue Cucumber::ArityMismatchError => e
109
- e.backtrace.unshift(self.backtrace_line)
110
- raise e
111
- end
112
- end
113
-
114
- def file_colon_line
115
- @proc.file_colon_line
116
- end
117
-
118
- def file
119
- @file ||= file_colon_line.split(':')[0]
120
- end
121
- end
122
- end