cucumber 1.2.1 → 1.2.2
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.
- data/.rvmrc +1 -1
- data/.travis.yml +3 -2
- data/DEVELOPERS.md +48 -0
- data/History.md +22 -3
- data/README.md +13 -31
- data/Rakefile +1 -0
- data/cucumber.gemspec +18 -17
- data/cucumber.yml +3 -2
- data/examples/i18n/cs/Rakefile +6 -0
- data/examples/i18n/cs/features/addition.feature +17 -0
- data/examples/i18n/cs/features/division.feature +11 -0
- data/examples/i18n/cs/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/cs/lib/calculator.rb +14 -0
- data/examples/i18n/hi/Rakefile +6 -0
- data/examples/i18n/hi/features/addition.feature +16 -0
- data/examples/i18n/hi/features/division.feature +10 -0
- data/examples/i18n/hi/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/hi/lib/calculator.rb +15 -0
- data/examples/python/README.textile +2 -1
- data/examples/ruby2python/README.textile +2 -1
- data/features/.cucumber/stepdefs.json +1688 -445
- data/features/assertions.feature +69 -0
- data/features/formatter_callbacks.feature +189 -0
- data/features/html_formatter.feature +19 -0
- data/features/json_formatter.feature +8 -4
- data/features/nested_steps_with_second_arg.feature +73 -0
- data/features/step_definitions.feature +65 -0
- data/features/step_definitions/cucumber_steps.rb +18 -3
- data/fixtures/self_test/features/support/env.rb +1 -1
- data/gem_tasks/cucumber.rake +5 -3
- data/gem_tasks/downloads.rb +3 -3
- data/gem_tasks/stats +4 -2
- data/gem_tasks/yard.rake +31 -13
- data/legacy_features/default_snippets.feature +3 -3
- data/legacy_features/language_help.feature +4 -0
- data/legacy_features/report_called_undefined_steps.feature +1 -1
- data/legacy_features/snippet.feature +3 -3
- data/legacy_features/snippets_when_using_star_keyword.feature +1 -1
- data/legacy_features/step_definitions/cucumber_steps.rb +4 -3
- data/legacy_features/support/env.rb +1 -1
- data/legacy_features/support/fake_wire_server.rb +9 -9
- data/lib/autotest/cucumber_mixin.rb +14 -14
- data/lib/autotest/discover.rb +2 -0
- data/lib/cucumber.rb +2 -2
- data/lib/cucumber/ast.rb +1 -1
- data/lib/cucumber/ast/background.rb +11 -7
- data/lib/cucumber/ast/comment.rb +2 -2
- data/lib/cucumber/ast/doc_string.rb +1 -1
- data/lib/cucumber/ast/examples.rb +1 -1
- data/lib/cucumber/ast/feature.rb +2 -2
- data/lib/cucumber/ast/feature_element.rb +1 -1
- data/lib/cucumber/ast/multiline_argument.rb +2 -2
- data/lib/cucumber/ast/names.rb +2 -2
- data/lib/cucumber/ast/outline_table.rb +4 -5
- data/lib/cucumber/ast/scenario.rb +14 -14
- data/lib/cucumber/ast/scenario_outline.rb +4 -4
- data/lib/cucumber/ast/step.rb +3 -3
- data/lib/cucumber/ast/step_collection.rb +5 -5
- data/lib/cucumber/ast/step_invocation.rb +8 -8
- data/lib/cucumber/ast/table.rb +40 -27
- data/lib/cucumber/ast/tree_walker.rb +9 -8
- data/lib/cucumber/ast/visitor.rb +1 -1
- data/lib/cucumber/cli/configuration.rb +10 -10
- data/lib/cucumber/cli/drb_client.rb +1 -1
- data/lib/cucumber/cli/main.rb +3 -3
- data/lib/cucumber/cli/options.rb +3 -2
- data/lib/cucumber/cli/profile_loader.rb +1 -1
- data/lib/cucumber/configuration.rb +12 -12
- data/lib/cucumber/constantize.rb +11 -2
- data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +1 -1
- data/lib/cucumber/core_ext/instance_exec.rb +4 -4
- data/lib/cucumber/core_ext/proc.rb +3 -3
- data/lib/cucumber/errors.rb +1 -1
- data/lib/cucumber/feature_file.rb +1 -1
- data/lib/cucumber/formatter/ansicolor.rb +36 -23
- data/lib/cucumber/formatter/console.rb +45 -25
- data/lib/cucumber/formatter/debug.rb +7 -7
- data/lib/cucumber/formatter/duration.rb +1 -1
- data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +7 -0
- data/lib/cucumber/formatter/gpretty.rb +1 -1
- data/lib/cucumber/formatter/html.rb +52 -53
- data/lib/cucumber/formatter/interceptor.rb +2 -2
- data/lib/cucumber/formatter/json.rb +1 -1
- data/lib/cucumber/formatter/json_pretty.rb +2 -1
- data/lib/cucumber/formatter/junit.rb +1 -1
- data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
- data/lib/cucumber/formatter/pretty.rb +12 -12
- data/lib/cucumber/formatter/progress.rb +5 -5
- data/lib/cucumber/formatter/rerun.rb +5 -5
- data/lib/cucumber/formatter/stepdefs.rb +1 -1
- data/lib/cucumber/formatter/steps.rb +6 -6
- data/lib/cucumber/formatter/summary.rb +6 -6
- data/lib/cucumber/formatter/unicode.rb +18 -18
- data/lib/cucumber/formatter/usage.rb +7 -7
- data/lib/cucumber/js_support/js_dsl.js +1 -1
- data/lib/cucumber/language_support.rb +1 -1
- data/lib/cucumber/parser/gherkin_builder.rb +33 -33
- data/lib/cucumber/platform.rb +3 -2
- data/lib/cucumber/py_support/py_dsl.py +2 -2
- data/lib/cucumber/py_support/py_language.py +2 -2
- data/lib/cucumber/py_support/py_language.rb +2 -2
- data/lib/cucumber/rake/task.rb +4 -3
- data/lib/cucumber/rb_support/rb_dsl.rb +10 -10
- data/lib/cucumber/rb_support/rb_language.rb +27 -19
- data/lib/cucumber/rb_support/rb_step_definition.rb +39 -11
- data/lib/cucumber/rb_support/rb_transform.rb +3 -3
- data/lib/cucumber/rb_support/rb_world.rb +15 -15
- data/lib/cucumber/rb_support/regexp_argument_matcher.rb +1 -1
- data/lib/cucumber/rspec/disable_option_parser.rb +1 -1
- data/lib/cucumber/rspec/doubles.rb +1 -1
- data/lib/cucumber/runtime.rb +11 -10
- data/lib/cucumber/runtime/features_loader.rb +6 -6
- data/lib/cucumber/runtime/for_programming_languages.rb +8 -15
- data/lib/cucumber/runtime/results.rb +6 -6
- data/lib/cucumber/runtime/support_code.rb +37 -28
- data/lib/cucumber/runtime/user_interface.rb +4 -4
- data/lib/cucumber/step_definition_light.rb +4 -4
- data/lib/cucumber/step_definitions.rb +2 -3
- data/lib/cucumber/step_match.rb +6 -6
- data/lib/cucumber/step_mother.rb +1 -1
- data/lib/cucumber/term/ansicolor.rb +22 -22
- data/lib/cucumber/wire_support/configuration.rb +11 -14
- data/lib/cucumber/wire_support/connection.rb +10 -9
- data/lib/cucumber/wire_support/request_handler.rb +3 -3
- data/lib/cucumber/wire_support/wire_exception.rb +3 -3
- data/lib/cucumber/wire_support/wire_language.rb +11 -11
- data/lib/cucumber/wire_support/wire_packet.rb +7 -5
- data/lib/cucumber/wire_support/wire_protocol.rb +6 -6
- data/lib/cucumber/wire_support/wire_protocol/requests.rb +20 -20
- data/lib/cucumber/wire_support/wire_step_definition.rb +4 -4
- data/spec/cucumber/ast/background_spec.rb +4 -4
- data/spec/cucumber/ast/doc_string_spec.rb +8 -8
- data/spec/cucumber/ast/feature_factory.rb +4 -4
- data/spec/cucumber/ast/feature_spec.rb +18 -18
- data/spec/cucumber/ast/outline_table_spec.rb +3 -3
- data/spec/cucumber/ast/step_spec.rb +4 -4
- data/spec/cucumber/ast/table_spec.rb +50 -29
- data/spec/cucumber/ast/tree_walker_spec.rb +12 -4
- data/spec/cucumber/broadcaster_spec.rb +1 -1
- data/spec/cucumber/cli/configuration_spec.rb +10 -4
- data/spec/cucumber/cli/drb_client_spec.rb +1 -1
- data/spec/cucumber/cli/main_spec.rb +28 -7
- data/spec/cucumber/cli/options_spec.rb +3 -3
- data/spec/cucumber/configuration_spec.rb +4 -4
- data/spec/cucumber/constantize_spec.rb +2 -0
- data/spec/cucumber/core_ext/proc_spec.rb +7 -7
- data/spec/cucumber/formatter/ansicolor_spec.rb +2 -2
- data/spec/cucumber/formatter/duration_spec.rb +2 -2
- data/spec/cucumber/formatter/html_spec.rb +31 -31
- data/spec/cucumber/formatter/interceptor_spec.rb +10 -0
- data/spec/cucumber/formatter/progress_spec.rb +1 -1
- data/spec/cucumber/formatter/spec_helper.rb +7 -7
- data/spec/cucumber/rake/forked_spec.rb +15 -2
- data/spec/cucumber/rake/rcov_spec.rb +2 -2
- data/spec/cucumber/rb_support/rb_language_spec.rb +34 -17
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +45 -35
- data/spec/cucumber/rb_support/rb_transform_spec.rb +3 -3
- data/spec/cucumber/runtime/for_programming_languages_spec.rb +31 -0
- data/spec/cucumber/runtime/results_spec.rb +5 -5
- data/spec/cucumber/runtime/support_code_spec.rb +13 -2
- data/spec/cucumber/runtime_spec.rb +7 -7
- data/spec/cucumber/step_match_spec.rb +2 -2
- data/spec/cucumber/wire_support/configuration_spec.rb +16 -6
- data/spec/cucumber/wire_support/connection_spec.rb +25 -11
- data/spec/cucumber/wire_support/wire_exception_spec.rb +3 -3
- data/spec/cucumber/wire_support/wire_language_spec.rb +3 -3
- data/spec/cucumber/wire_support/wire_packet_spec.rb +4 -4
- data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +98 -128
- data/legacy_features/html_formatter.feature +0 -8
- data/legacy_features/html_formatter/a.html +0 -561
data/lib/cucumber/platform.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rbconfig'
|
|
4
4
|
|
5
5
|
module Cucumber
|
6
6
|
unless defined?(Cucumber::VERSION)
|
7
|
-
VERSION = '1.2.
|
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
|
-
|
25
|
+
RUBY_1_8_7 ? m : "#{m}:#{encoding}"
|
25
26
|
end
|
26
27
|
end
|
27
28
|
self.use_full_backtrace = false
|
@@ -5,7 +5,7 @@ module Cucumber
|
|
5
5
|
class PyLanguage
|
6
6
|
include LanguageSupport::LanguageMethods
|
7
7
|
|
8
|
-
def initialize(
|
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
|
data/lib/cucumber/rake/task.rb
CHANGED
@@ -92,7 +92,8 @@ module Cucumber
|
|
92
92
|
|
93
93
|
def cmd
|
94
94
|
if use_bundler
|
95
|
-
|
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
|
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(
|
42
|
-
@
|
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
|
-
|
58
|
+
@assertions_module = find_best_assertions_module
|
47
59
|
end
|
48
60
|
|
49
|
-
def
|
61
|
+
def find_best_assertions_module
|
50
62
|
begin
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
62
|
-
rescue
|
63
|
-
|
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}
|
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(@
|
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.
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
39
|
+
Regexp.new("^#{p}$")
|
32
40
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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 = @
|
17
|
+
rb = @__cucumber_runtime.load_programming_language('rb')
|
18
18
|
rb.execute_transforms([arg]).first
|
19
19
|
end
|
20
20
|
|
21
|
-
attr_writer :
|
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
|
-
@
|
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
|
-
@
|
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
|
-
@
|
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
|
-
@
|
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(
|
45
|
-
@
|
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
|
-
@
|
55
|
+
@__cucumber_runtime.puts(*messages)
|
56
56
|
end
|
57
57
|
|
58
58
|
# See StepMother#ask
|
59
59
|
def ask(question, timeout_seconds=60)
|
60
|
-
@
|
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
|
-
@
|
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
|
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
|