cucumber 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. data/.rvmrc +1 -1
  2. data/.travis.yml +3 -2
  3. data/DEVELOPERS.md +48 -0
  4. data/History.md +22 -3
  5. data/README.md +13 -31
  6. data/Rakefile +1 -0
  7. data/cucumber.gemspec +18 -17
  8. data/cucumber.yml +3 -2
  9. data/examples/i18n/cs/Rakefile +6 -0
  10. data/examples/i18n/cs/features/addition.feature +17 -0
  11. data/examples/i18n/cs/features/division.feature +11 -0
  12. data/examples/i18n/cs/features/step_definitons/calculator_steps.rb +24 -0
  13. data/examples/i18n/cs/lib/calculator.rb +14 -0
  14. data/examples/i18n/hi/Rakefile +6 -0
  15. data/examples/i18n/hi/features/addition.feature +16 -0
  16. data/examples/i18n/hi/features/division.feature +10 -0
  17. data/examples/i18n/hi/features/step_definitons/calculator_steps.rb +24 -0
  18. data/examples/i18n/hi/lib/calculator.rb +15 -0
  19. data/examples/python/README.textile +2 -1
  20. data/examples/ruby2python/README.textile +2 -1
  21. data/features/.cucumber/stepdefs.json +1688 -445
  22. data/features/assertions.feature +69 -0
  23. data/features/formatter_callbacks.feature +189 -0
  24. data/features/html_formatter.feature +19 -0
  25. data/features/json_formatter.feature +8 -4
  26. data/features/nested_steps_with_second_arg.feature +73 -0
  27. data/features/step_definitions.feature +65 -0
  28. data/features/step_definitions/cucumber_steps.rb +18 -3
  29. data/fixtures/self_test/features/support/env.rb +1 -1
  30. data/gem_tasks/cucumber.rake +5 -3
  31. data/gem_tasks/downloads.rb +3 -3
  32. data/gem_tasks/stats +4 -2
  33. data/gem_tasks/yard.rake +31 -13
  34. data/legacy_features/default_snippets.feature +3 -3
  35. data/legacy_features/language_help.feature +4 -0
  36. data/legacy_features/report_called_undefined_steps.feature +1 -1
  37. data/legacy_features/snippet.feature +3 -3
  38. data/legacy_features/snippets_when_using_star_keyword.feature +1 -1
  39. data/legacy_features/step_definitions/cucumber_steps.rb +4 -3
  40. data/legacy_features/support/env.rb +1 -1
  41. data/legacy_features/support/fake_wire_server.rb +9 -9
  42. data/lib/autotest/cucumber_mixin.rb +14 -14
  43. data/lib/autotest/discover.rb +2 -0
  44. data/lib/cucumber.rb +2 -2
  45. data/lib/cucumber/ast.rb +1 -1
  46. data/lib/cucumber/ast/background.rb +11 -7
  47. data/lib/cucumber/ast/comment.rb +2 -2
  48. data/lib/cucumber/ast/doc_string.rb +1 -1
  49. data/lib/cucumber/ast/examples.rb +1 -1
  50. data/lib/cucumber/ast/feature.rb +2 -2
  51. data/lib/cucumber/ast/feature_element.rb +1 -1
  52. data/lib/cucumber/ast/multiline_argument.rb +2 -2
  53. data/lib/cucumber/ast/names.rb +2 -2
  54. data/lib/cucumber/ast/outline_table.rb +4 -5
  55. data/lib/cucumber/ast/scenario.rb +14 -14
  56. data/lib/cucumber/ast/scenario_outline.rb +4 -4
  57. data/lib/cucumber/ast/step.rb +3 -3
  58. data/lib/cucumber/ast/step_collection.rb +5 -5
  59. data/lib/cucumber/ast/step_invocation.rb +8 -8
  60. data/lib/cucumber/ast/table.rb +40 -27
  61. data/lib/cucumber/ast/tree_walker.rb +9 -8
  62. data/lib/cucumber/ast/visitor.rb +1 -1
  63. data/lib/cucumber/cli/configuration.rb +10 -10
  64. data/lib/cucumber/cli/drb_client.rb +1 -1
  65. data/lib/cucumber/cli/main.rb +3 -3
  66. data/lib/cucumber/cli/options.rb +3 -2
  67. data/lib/cucumber/cli/profile_loader.rb +1 -1
  68. data/lib/cucumber/configuration.rb +12 -12
  69. data/lib/cucumber/constantize.rb +11 -2
  70. data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +1 -1
  71. data/lib/cucumber/core_ext/instance_exec.rb +4 -4
  72. data/lib/cucumber/core_ext/proc.rb +3 -3
  73. data/lib/cucumber/errors.rb +1 -1
  74. data/lib/cucumber/feature_file.rb +1 -1
  75. data/lib/cucumber/formatter/ansicolor.rb +36 -23
  76. data/lib/cucumber/formatter/console.rb +45 -25
  77. data/lib/cucumber/formatter/debug.rb +7 -7
  78. data/lib/cucumber/formatter/duration.rb +1 -1
  79. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +7 -0
  80. data/lib/cucumber/formatter/gpretty.rb +1 -1
  81. data/lib/cucumber/formatter/html.rb +52 -53
  82. data/lib/cucumber/formatter/interceptor.rb +2 -2
  83. data/lib/cucumber/formatter/json.rb +1 -1
  84. data/lib/cucumber/formatter/json_pretty.rb +2 -1
  85. data/lib/cucumber/formatter/junit.rb +1 -1
  86. data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
  87. data/lib/cucumber/formatter/pretty.rb +12 -12
  88. data/lib/cucumber/formatter/progress.rb +5 -5
  89. data/lib/cucumber/formatter/rerun.rb +5 -5
  90. data/lib/cucumber/formatter/stepdefs.rb +1 -1
  91. data/lib/cucumber/formatter/steps.rb +6 -6
  92. data/lib/cucumber/formatter/summary.rb +6 -6
  93. data/lib/cucumber/formatter/unicode.rb +18 -18
  94. data/lib/cucumber/formatter/usage.rb +7 -7
  95. data/lib/cucumber/js_support/js_dsl.js +1 -1
  96. data/lib/cucumber/language_support.rb +1 -1
  97. data/lib/cucumber/parser/gherkin_builder.rb +33 -33
  98. data/lib/cucumber/platform.rb +3 -2
  99. data/lib/cucumber/py_support/py_dsl.py +2 -2
  100. data/lib/cucumber/py_support/py_language.py +2 -2
  101. data/lib/cucumber/py_support/py_language.rb +2 -2
  102. data/lib/cucumber/rake/task.rb +4 -3
  103. data/lib/cucumber/rb_support/rb_dsl.rb +10 -10
  104. data/lib/cucumber/rb_support/rb_language.rb +27 -19
  105. data/lib/cucumber/rb_support/rb_step_definition.rb +39 -11
  106. data/lib/cucumber/rb_support/rb_transform.rb +3 -3
  107. data/lib/cucumber/rb_support/rb_world.rb +15 -15
  108. data/lib/cucumber/rb_support/regexp_argument_matcher.rb +1 -1
  109. data/lib/cucumber/rspec/disable_option_parser.rb +1 -1
  110. data/lib/cucumber/rspec/doubles.rb +1 -1
  111. data/lib/cucumber/runtime.rb +11 -10
  112. data/lib/cucumber/runtime/features_loader.rb +6 -6
  113. data/lib/cucumber/runtime/for_programming_languages.rb +8 -15
  114. data/lib/cucumber/runtime/results.rb +6 -6
  115. data/lib/cucumber/runtime/support_code.rb +37 -28
  116. data/lib/cucumber/runtime/user_interface.rb +4 -4
  117. data/lib/cucumber/step_definition_light.rb +4 -4
  118. data/lib/cucumber/step_definitions.rb +2 -3
  119. data/lib/cucumber/step_match.rb +6 -6
  120. data/lib/cucumber/step_mother.rb +1 -1
  121. data/lib/cucumber/term/ansicolor.rb +22 -22
  122. data/lib/cucumber/wire_support/configuration.rb +11 -14
  123. data/lib/cucumber/wire_support/connection.rb +10 -9
  124. data/lib/cucumber/wire_support/request_handler.rb +3 -3
  125. data/lib/cucumber/wire_support/wire_exception.rb +3 -3
  126. data/lib/cucumber/wire_support/wire_language.rb +11 -11
  127. data/lib/cucumber/wire_support/wire_packet.rb +7 -5
  128. data/lib/cucumber/wire_support/wire_protocol.rb +6 -6
  129. data/lib/cucumber/wire_support/wire_protocol/requests.rb +20 -20
  130. data/lib/cucumber/wire_support/wire_step_definition.rb +4 -4
  131. data/spec/cucumber/ast/background_spec.rb +4 -4
  132. data/spec/cucumber/ast/doc_string_spec.rb +8 -8
  133. data/spec/cucumber/ast/feature_factory.rb +4 -4
  134. data/spec/cucumber/ast/feature_spec.rb +18 -18
  135. data/spec/cucumber/ast/outline_table_spec.rb +3 -3
  136. data/spec/cucumber/ast/step_spec.rb +4 -4
  137. data/spec/cucumber/ast/table_spec.rb +50 -29
  138. data/spec/cucumber/ast/tree_walker_spec.rb +12 -4
  139. data/spec/cucumber/broadcaster_spec.rb +1 -1
  140. data/spec/cucumber/cli/configuration_spec.rb +10 -4
  141. data/spec/cucumber/cli/drb_client_spec.rb +1 -1
  142. data/spec/cucumber/cli/main_spec.rb +28 -7
  143. data/spec/cucumber/cli/options_spec.rb +3 -3
  144. data/spec/cucumber/configuration_spec.rb +4 -4
  145. data/spec/cucumber/constantize_spec.rb +2 -0
  146. data/spec/cucumber/core_ext/proc_spec.rb +7 -7
  147. data/spec/cucumber/formatter/ansicolor_spec.rb +2 -2
  148. data/spec/cucumber/formatter/duration_spec.rb +2 -2
  149. data/spec/cucumber/formatter/html_spec.rb +31 -31
  150. data/spec/cucumber/formatter/interceptor_spec.rb +10 -0
  151. data/spec/cucumber/formatter/progress_spec.rb +1 -1
  152. data/spec/cucumber/formatter/spec_helper.rb +7 -7
  153. data/spec/cucumber/rake/forked_spec.rb +15 -2
  154. data/spec/cucumber/rake/rcov_spec.rb +2 -2
  155. data/spec/cucumber/rb_support/rb_language_spec.rb +34 -17
  156. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +45 -35
  157. data/spec/cucumber/rb_support/rb_transform_spec.rb +3 -3
  158. data/spec/cucumber/runtime/for_programming_languages_spec.rb +31 -0
  159. data/spec/cucumber/runtime/results_spec.rb +5 -5
  160. data/spec/cucumber/runtime/support_code_spec.rb +13 -2
  161. data/spec/cucumber/runtime_spec.rb +7 -7
  162. data/spec/cucumber/step_match_spec.rb +2 -2
  163. data/spec/cucumber/wire_support/configuration_spec.rb +16 -6
  164. data/spec/cucumber/wire_support/connection_spec.rb +25 -11
  165. data/spec/cucumber/wire_support/wire_exception_spec.rb +3 -3
  166. data/spec/cucumber/wire_support/wire_language_spec.rb +3 -3
  167. data/spec/cucumber/wire_support/wire_packet_spec.rb +4 -4
  168. data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
  169. data/spec/spec_helper.rb +2 -2
  170. metadata +98 -128
  171. data/legacy_features/html_formatter.feature +0 -8
  172. data/legacy_features/html_formatter/a.html +0 -561
@@ -4,7 +4,7 @@ require 'rbconfig'
4
4
 
5
5
  module Cucumber
6
6
  unless defined?(Cucumber::VERSION)
7
- VERSION = '1.2.1'
7
+ VERSION = '1.2.2'
8
8
  BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
9
9
  LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib')
10
10
  JRUBY = defined?(JRUBY_VERSION)
@@ -14,6 +14,7 @@ unless defined?(Cucumber::VERSION)
14
14
  WINDOWS_MRI = WINDOWS && !JRUBY && !IRONRUBY
15
15
  RAILS = defined?(Rails)
16
16
  RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
17
+ RUBY_2_0 = RUBY_VERSION =~ /^2\.0/
17
18
  RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
18
19
  RUBY_1_8_7 = RUBY_VERSION =~ /^1\.8\.7/
19
20
 
@@ -21,7 +22,7 @@ unless defined?(Cucumber::VERSION)
21
22
  attr_accessor :use_full_backtrace
22
23
 
23
24
  def file_mode(m, encoding="UTF-8") #:nodoc:
24
- RUBY_1_9 ? "#{m}:#{encoding}" : m
25
+ RUBY_1_8_7 ? m : "#{m}:#{encoding}"
25
26
  end
26
27
  end
27
28
  self.use_full_backtrace = false
@@ -3,8 +3,8 @@ import py_language
3
3
  class Given(object):
4
4
  def __init__(self, regexp):
5
5
  self.regexp = regexp
6
-
6
+
7
7
  def __call__(self, f):
8
8
  py_language.register_step_def(self.regexp, f)
9
9
  return f
10
-
10
+
@@ -5,6 +5,6 @@ step_defs = {}
5
5
  def register_step_def(regexp, f):
6
6
  print "Got a step def: ", regexp
7
7
  step_defs[regexp] = f
8
-
8
+
9
9
  def step_matches(step_name, name_to_report):
10
- print "WTF: " + step_name
10
+ print "WTF: " + step_name
@@ -5,7 +5,7 @@ module Cucumber
5
5
  class PyLanguage
6
6
  include LanguageSupport::LanguageMethods
7
7
 
8
- def initialize(step_mother)
8
+ def initialize(runtime)
9
9
  @step_def_files = []
10
10
  #
11
11
  # @python_path = ENV['PYTHONPATH'] ? ENV['PYTHONPATH'].split(':') : []
@@ -77,4 +77,4 @@ class String #:nodoc:
77
77
  tail == str
78
78
  end
79
79
  end
80
- end
80
+ end
@@ -92,7 +92,8 @@ module Cucumber
92
92
 
93
93
  def cmd
94
94
  if use_bundler
95
- [ Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'cucumber', @cucumber_opts,
95
+ bundle_cmd = Gem.default_exec_format % 'bundle'
96
+ [ Cucumber::RUBY_BINARY, '-S', bundle_cmd, 'exec', 'cucumber', @cucumber_opts,
96
97
  @feature_files ].flatten
97
98
  else
98
99
  [ Cucumber::RUBY_BINARY, '-I', load_path(@libs), quoted_binary(@cucumber_bin),
@@ -121,7 +122,7 @@ module Cucumber
121
122
  quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
122
123
  end
123
124
  end
124
-
125
+
125
126
  end
126
127
 
127
128
  LIB = File.expand_path(File.dirname(__FILE__) + '/../..') #:nodoc:
@@ -143,7 +144,7 @@ module Cucumber
143
144
  # true, +fork+ is implicit.
144
145
  attr_accessor :rcov
145
146
  def rcov=(flag)
146
- if(flag && Cucumber::RUBY_1_9)
147
+ if flag && !Cucumber::RUBY_1_8_7
147
148
  raise failed + "RCov only works on Ruby 1.8.x. You may want to use SimpleCov: https://github.com/colszowka/simplecov" + reset
148
149
  end
149
150
  @rcov = flag
@@ -6,7 +6,7 @@ module Cucumber
6
6
  module RbDsl
7
7
  class << self
8
8
  attr_writer :rb_language
9
-
9
+
10
10
  def alias_adverb(adverb)
11
11
  alias_method adverb, :register_rb_step_definition
12
12
  end
@@ -20,7 +20,7 @@ module Cucumber
20
20
  end
21
21
 
22
22
  def register_rb_transform(regexp, proc)
23
- @rb_language.register_rb_transform(regexp, proc)
23
+ @rb_language.register_rb_transform(regexp, proc)
24
24
  end
25
25
 
26
26
  def register_rb_step_definition(regexp, proc_or_sym, options = {})
@@ -33,9 +33,9 @@ module Cucumber
33
33
  # Object that the scenario's steps will run within. Any +world_modules+
34
34
  # will be mixed into this Object (via Object#extend).
35
35
  #
36
- # This method is typically called from one or more Ruby scripts under
37
- # <tt>features/support</tt>. You can call this method as many times as you
38
- # like (to register more modules), but if you try to register more than
36
+ # This method is typically called from one or more Ruby scripts under
37
+ # <tt>features/support</tt>. You can call this method as many times as you
38
+ # like (to register more modules), but if you try to register more than
39
39
  # one Proc you will get an error.
40
40
  #
41
41
  # Cucumber will not yield anything to the +proc+. Examples:
@@ -71,13 +71,13 @@ module Cucumber
71
71
  RbDsl.register_rb_hook('around', tag_expressions, proc)
72
72
  end
73
73
 
74
- # Registers a proc that will run after each Step. You can register as
74
+ # Registers a proc that will run after each Step. You can register as
75
75
  # as you want (typically from ruby scripts under <tt>support/hooks.rb</tt>).
76
76
  def AfterStep(*tag_expressions, &proc)
77
77
  RbDsl.register_rb_hook('after_step', tag_expressions, proc)
78
78
  end
79
79
 
80
- # Registers a proc that will be called with a step definition argument if it
80
+ # Registers a proc that will be called with a step definition argument if it
81
81
  # matches the pattern passed as the first argument to Transform. Alternatively, if
82
82
  # the pattern contains captures then they will be yielded as arguments to the
83
83
  # provided proc. The return value of the proc is consequently yielded to the
@@ -85,13 +85,13 @@ module Cucumber
85
85
  def Transform(regexp, &proc)
86
86
  RbDsl.register_rb_transform(regexp, proc)
87
87
  end
88
-
89
- # Registers a proc that will run after Cucumber is configured. You can register as
88
+
89
+ # Registers a proc that will run after Cucumber is configured. You can register as
90
90
  # as you want (typically from ruby scripts under <tt>support/hooks.rb</tt>).
91
91
  # TODO: Deprecate this
92
92
  def AfterConfiguration(&proc)
93
93
  RbDsl.register_rb_hook('after_configuration', [], proc)
94
- end
94
+ end
95
95
 
96
96
  # Registers a new Ruby StepDefinition. This method is aliased
97
97
  # to <tt>Given</tt>, <tt>When</tt> and <tt>Then</tt>, and
@@ -5,6 +5,18 @@ require 'cucumber/rb_support/rb_step_definition'
5
5
  require 'cucumber/rb_support/rb_hook'
6
6
  require 'cucumber/rb_support/rb_transform'
7
7
 
8
+ begin
9
+ require 'rspec/expectations'
10
+ rescue LoadError
11
+ begin
12
+ require 'spec/expectations'
13
+ require 'spec/runner/differs/default'
14
+ require 'ostruct'
15
+ rescue LoadError
16
+ require 'test/unit/assertions'
17
+ end
18
+ end
19
+
8
20
  module Cucumber
9
21
  module RbSupport
10
22
  # Raised if a World block returns Nil.
@@ -38,29 +50,25 @@ module Cucumber
38
50
  RbWorld.alias_adverb(adverb)
39
51
  end
40
52
 
41
- def initialize(step_mother)
42
- @step_mother = step_mother
53
+ def initialize(runtime)
54
+ @runtime = runtime
43
55
  @step_definitions = []
44
56
  RbDsl.rb_language = self
45
57
  @world_proc = @world_modules = nil
46
- enable_rspec_expectations_if_available
58
+ @assertions_module = find_best_assertions_module
47
59
  end
48
60
 
49
- def enable_rspec_expectations_if_available
61
+ def find_best_assertions_module
50
62
  begin
51
- # RSpec >=2.0
52
- require 'rspec/expectations'
53
- @rspec_matchers = ::RSpec::Matchers
54
- rescue LoadError => try_rspec_1_2_4_or_higher
63
+ ::RSpec::Matchers
64
+ rescue NameError
65
+ # RSpec >=1.2.4
55
66
  begin
56
- require 'spec/expectations'
57
- require 'spec/runner/differs/default'
58
- require 'ostruct'
59
67
  options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
60
68
  Spec::Expectations.differ = Spec::Expectations::Differs::Default.new(options)
61
- @rspec_matchers = ::Spec::Matchers
62
- rescue LoadError => give_up
63
- @rspec_matchers = Module.new{}
69
+ ::Spec::Matchers
70
+ rescue NameError
71
+ ::Test::Unit::Assertions
64
72
  end
65
73
  end
66
74
  end
@@ -93,7 +101,7 @@ module Cucumber
93
101
  multiline_class_comment = "# #{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n "
94
102
  end
95
103
 
96
- "#{code_keyword} /^#{snippet_pattern}$/ do#{block_arg_string}\n #{multiline_class_comment}pending # express the regexp above with the code you wish you had\nend"
104
+ "#{code_keyword}(/^#{snippet_pattern}$/) do#{block_arg_string}\n #{multiline_class_comment}pending # express the regexp above with the code you wish you had\nend"
97
105
  end
98
106
 
99
107
  def begin_rb_scenario(scenario)
@@ -128,13 +136,13 @@ module Cucumber
128
136
  def load_code_file(code_file)
129
137
  load File.expand_path(code_file) # This will cause self.add_step_definition, self.add_hook, and self.add_transform to be called from RbDsl
130
138
  end
131
-
139
+
132
140
  protected
133
141
 
134
142
  def begin_scenario(scenario)
135
143
  begin_rb_scenario(scenario)
136
144
  end
137
-
145
+
138
146
  def end_scenario
139
147
  @current_world = nil
140
148
  end
@@ -152,14 +160,14 @@ module Cucumber
152
160
 
153
161
  def extend_world
154
162
  @current_world.extend(RbWorld)
155
- @current_world.extend(@rspec_matchers)
163
+ @current_world.extend(@assertions_module)
156
164
  (@world_modules || []).each do |mod|
157
165
  @current_world.extend(mod)
158
166
  end
159
167
  end
160
168
 
161
169
  def connect_world(scenario)
162
- @current_world.__cucumber_step_mother = @step_mother
170
+ @current_world.__cucumber_runtime = @runtime
163
171
  @current_world.__natural_language = scenario.language
164
172
  end
165
173
 
@@ -23,21 +23,49 @@ module Cucumber
23
23
  end
24
24
  end
25
25
 
26
- def initialize(rb_language, regexp, proc_or_sym, options)
27
- raise MissingProc if proc_or_sym.nil?
28
- if String === regexp
29
- p = Regexp.escape(regexp)
26
+ class << self
27
+ def new(rb_language, pattern, proc_or_sym, options)
28
+ raise MissingProc if proc_or_sym.nil?
29
+ super rb_language, parse_pattern(pattern), create_proc(proc_or_sym, options)
30
+ end
31
+
32
+ private
33
+
34
+ def parse_pattern(pattern)
35
+ return pattern if pattern.is_a?(Regexp)
36
+ raise ArgumentError unless pattern.is_a?(String)
37
+ p = Regexp.escape(pattern)
30
38
  p = p.gsub(/\\\$\w+/, '(.*)') # Replace $var with (.*)
31
- regexp = Regexp.new("^#{p}$")
39
+ Regexp.new("^#{p}$")
32
40
  end
33
- @rb_language, @regexp, @proc = rb_language, regexp, proc_or_sym
34
- if @proc.kind_of? Symbol
35
- @proc = lambda do |*args|
36
- target = options[:on] ? instance_exec(&options[:on]) : self
37
- target.send(proc_or_sym, *args)
41
+
42
+ def create_proc(proc_or_sym, options)
43
+ return proc_or_sym if proc_or_sym.is_a?(Proc)
44
+ raise ArgumentError unless proc_or_sym.is_a?(Symbol)
45
+ message = proc_or_sym
46
+ target_proc = parse_target_proc_from(options)
47
+ lambda do |*args|
48
+ target = instance_exec(&target_proc)
49
+ target.send(message, *args)
38
50
  end
39
51
  end
40
52
 
53
+ def parse_target_proc_from(options)
54
+ return lambda { self } unless options.key?(:on)
55
+ target = options[:on]
56
+ case target
57
+ when Proc
58
+ target
59
+ when Symbol
60
+ lambda { self.send(target) }
61
+ else
62
+ lambda { raise ArgumentError, "Target must be a symbol or a proc" }
63
+ end
64
+ end
65
+ end
66
+
67
+ def initialize(rb_language, regexp, proc)
68
+ @rb_language, @regexp, @proc = rb_language, regexp, proc
41
69
  @rb_language.available_step_definition(regexp_source, file_colon_line)
42
70
  end
43
71
 
@@ -85,7 +113,7 @@ module Cucumber
85
113
  ":#{@proc}"
86
114
  end
87
115
  end
88
-
116
+
89
117
  def file
90
118
  @file ||= file_colon_line.split(':')[0]
91
119
  end
@@ -32,16 +32,16 @@ module Cucumber
32
32
  @rb_language.current_world.cucumber_instance_exec(true, @regexp.inspect, *args, &@proc)
33
33
  end
34
34
  end
35
-
35
+
36
36
  def to_s
37
37
  convert_captures(strip_anchors(@regexp.source))
38
38
  end
39
-
39
+
40
40
  private
41
41
  def convert_captures(regexp_source)
42
42
  regexp_source.gsub(/(\()(?!\?:)/,'(?:')
43
43
  end
44
-
44
+
45
45
  def strip_captures(regexp_source)
46
46
  regexp_source.
47
47
  gsub(/(\()/, '').
@@ -14,35 +14,35 @@ module Cucumber
14
14
 
15
15
  # Call a Transform with a string from another Transform definition
16
16
  def Transform(arg)
17
- rb = @__cucumber_step_mother.load_programming_language('rb')
17
+ rb = @__cucumber_runtime.load_programming_language('rb')
18
18
  rb.execute_transforms([arg]).first
19
19
  end
20
20
 
21
- attr_writer :__cucumber_step_mother, :__natural_language
21
+ attr_writer :__cucumber_runtime, :__natural_language
22
22
 
23
23
  def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
24
24
  STDERR.puts AnsiEscapes.failed + "WARNING: Using 'Given/When/Then' in step definitions is deprecated, use 'step' to call other steps instead:" + caller[0] + AnsiEscapes.reset
25
- @__cucumber_step_mother.invoke(name, multiline_argument)
25
+ @__cucumber_runtime.invoke(name, multiline_argument)
26
26
  end
27
27
 
28
28
  # Invoke a single step.
29
29
  def step(name, multiline_argument=nil)
30
- @__cucumber_step_mother.invoke(name, multiline_argument)
30
+ @__cucumber_runtime.invoke(name, multiline_argument)
31
31
  end
32
32
 
33
33
  # See StepMother#invoke_steps
34
34
  def steps(steps_text)
35
- @__cucumber_step_mother.invoke_steps(steps_text, @__natural_language, caller[0])
35
+ @__cucumber_runtime.invoke_steps(steps_text, @__natural_language, caller[0])
36
36
  end
37
37
 
38
38
  # See StepMother#table
39
39
  def table(text_or_table, file=nil, line_offset=0)
40
- @__cucumber_step_mother.table(text_or_table, file, line_offset)
40
+ @__cucumber_runtime.table(text_or_table, file, line_offset)
41
41
  end
42
42
 
43
43
  # See StepMother#doc_string
44
- def doc_string(string_with_triple_quotes, file=nil, line_offset=0)
45
- @__cucumber_step_mother.doc_string(string_with_triple_quotes, file, line_offset)
44
+ def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
45
+ @__cucumber_runtime.doc_string(string_without_triple_quotes, content_type, line_offset)
46
46
  end
47
47
 
48
48
  def announce(*messages)
@@ -52,17 +52,17 @@ module Cucumber
52
52
 
53
53
  # See StepMother#puts
54
54
  def puts(*messages)
55
- @__cucumber_step_mother.puts(*messages)
55
+ @__cucumber_runtime.puts(*messages)
56
56
  end
57
57
 
58
58
  # See StepMother#ask
59
59
  def ask(question, timeout_seconds=60)
60
- @__cucumber_step_mother.ask(question, timeout_seconds)
60
+ @__cucumber_runtime.ask(question, timeout_seconds)
61
61
  end
62
62
 
63
63
  # See StepMother#embed
64
64
  def embed(file, mime_type, label='Screenshot')
65
- @__cucumber_step_mother.embed(file, mime_type, label)
65
+ @__cucumber_runtime.embed(file, mime_type, label)
66
66
  end
67
67
 
68
68
  # Mark the matched step as pending.
@@ -70,7 +70,7 @@ module Cucumber
70
70
  if block_given?
71
71
  begin
72
72
  yield
73
- rescue Exception => e
73
+ rescue Exception
74
74
  raise Pending.new(message)
75
75
  end
76
76
  raise Pending.new("Expected pending '#{message}' to fail. No Error was raised. No longer pending?")
@@ -80,11 +80,11 @@ module Cucumber
80
80
  end
81
81
 
82
82
  # The default implementation of Object#inspect recursively
83
- # traverses all instance variables and invokes inspect.
83
+ # traverses all instance variables and invokes inspect.
84
84
  # This can be time consuming if the object graph is large.
85
85
  #
86
- # This can cause unnecessary delays when certain exceptions
87
- # occur. For example, MRI internally invokes #inspect on an
86
+ # This can cause unnecessary delays when certain exceptions
87
+ # occur. For example, MRI internally invokes #inspect on an
88
88
  # object that raises a NoMethodError. (JRuby does not do this).
89
89
  #
90
90
  # A World object can have many references created by the user
@@ -18,4 +18,4 @@ module Cucumber
18
18
  end
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -8,7 +8,7 @@ module Spec #:nodoc:
8
8
  class OptionParser < ::OptionParser #:nodoc:
9
9
  NEUTERED_RSPEC = Object.new
10
10
  def NEUTERED_RSPEC.method_missing(m, *args); self; end
11
-
11
+
12
12
  def self.method_added(m)
13
13
  unless @__neutering_rspec
14
14
  @__neutering_rspec = true
@@ -13,4 +13,4 @@ After do
13
13
  ensure
14
14
  RSpec::Mocks::teardown
15
15
  end
16
- end
16
+ end