cucumber 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -6
- data/CONTRIBUTING.md +3 -1
- data/Gemfile +1 -1
- data/History.md +17 -0
- data/README.md +3 -3
- data/bin/cucumber +1 -2
- data/cucumber.gemspec +2 -2
- data/examples/i18n/ht/features/adisyon.feature +7 -7
- data/features/docs/api/listen_for_events.feature +58 -0
- data/features/docs/cli/fail_fast.feature +46 -0
- data/features/docs/defining_steps/nested_steps_with_second_arg.feature +3 -22
- data/features/docs/extending_cucumber/custom_formatter.feature +40 -4
- data/features/docs/gherkin/doc_strings.feature +5 -5
- data/features/docs/gherkin/language_help.feature +15 -15
- data/features/docs/gherkin/using_descriptions.feature +0 -5
- data/lib/cucumber/cli/configuration.rb +10 -92
- data/lib/cucumber/cli/main.rb +1 -7
- data/lib/cucumber/cli/options.rb +47 -12
- data/lib/cucumber/configuration.rb +195 -7
- data/lib/cucumber/events.rb +20 -0
- data/lib/cucumber/events/after_test_case.rb +25 -0
- data/lib/cucumber/events/after_test_step.rb +30 -0
- data/lib/cucumber/events/before_test_case.rb +18 -0
- data/lib/cucumber/events/before_test_step.rb +23 -0
- data/lib/cucumber/events/bus.rb +86 -0
- data/lib/cucumber/events/step_match.rb +23 -0
- data/lib/cucumber/filters/prepare_world.rb +2 -2
- data/lib/cucumber/formatter/backtrace_filter.rb +9 -8
- data/lib/cucumber/formatter/console.rb +1 -1
- data/lib/cucumber/formatter/event_bus_report.rb +37 -0
- data/lib/cucumber/formatter/fail_fast.rb +18 -0
- data/lib/cucumber/formatter/html.rb +1 -1
- data/lib/cucumber/formatter/io.rb +3 -1
- data/lib/cucumber/formatter/json.rb +19 -1
- data/lib/cucumber/formatter/legacy_api/adapter.rb +5 -13
- data/lib/cucumber/formatter/legacy_api/ast.rb +2 -2
- data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +3 -1
- data/lib/cucumber/formatter/pretty.rb +5 -7
- data/lib/cucumber/formatter/progress.rb +1 -1
- data/lib/cucumber/formatter/rerun.rb +1 -1
- data/lib/cucumber/formatter/steps.rb +1 -1
- data/lib/cucumber/formatter/usage.rb +12 -8
- data/lib/cucumber/gherkin/data_table_parser.rb +23 -0
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +99 -0
- data/lib/cucumber/gherkin/formatter/argument.rb +17 -0
- data/lib/cucumber/gherkin/formatter/escaping.rb +17 -0
- data/lib/cucumber/gherkin/formatter/hashable.rb +27 -0
- data/lib/cucumber/gherkin/i18n.rb +15 -0
- data/lib/cucumber/gherkin/steps_parser.rb +41 -0
- data/lib/cucumber/language_support/language_methods.rb +6 -5
- data/lib/cucumber/multiline_argument.rb +0 -3
- data/lib/cucumber/multiline_argument/data_table.rb +6 -5
- data/lib/cucumber/multiline_argument/doc_string.rb +1 -2
- data/lib/cucumber/platform.rb +1 -1
- data/lib/cucumber/rake/task.rb +2 -2
- data/lib/cucumber/rb_support/rb_hook.rb +1 -6
- data/lib/cucumber/rb_support/rb_language.rb +15 -5
- data/lib/cucumber/rb_support/rb_step_definition.rb +11 -17
- data/lib/cucumber/rb_support/rb_world.rb +6 -4
- data/lib/cucumber/rb_support/regexp_argument_matcher.rb +2 -2
- data/lib/cucumber/runtime.rb +36 -16
- data/lib/cucumber/runtime/support_code.rb +19 -15
- data/lib/cucumber/step_definition_light.rb +5 -5
- data/lib/cucumber/step_definitions.rb +2 -2
- data/lib/cucumber/step_match.rb +11 -2
- data/lib/cucumber/wire_support/wire_protocol/requests.rb +2 -2
- data/lib/cucumber/wire_support/wire_step_definition.rb +4 -2
- data/{spec → lib}/simplecov_setup.rb +0 -0
- data/spec/cucumber/cli/configuration_spec.rb +2 -104
- data/spec/cucumber/cli/main_spec.rb +0 -22
- data/spec/cucumber/cli/options_spec.rb +3 -1
- data/spec/cucumber/configuration_spec.rb +123 -0
- data/spec/cucumber/events/bus_spec.rb +94 -0
- data/spec/cucumber/formatter/event_bus_report_spec.rb +79 -0
- data/spec/cucumber/formatter/fail_fast_spec.rb +88 -0
- data/spec/cucumber/formatter/json_spec.rb +43 -1
- data/spec/cucumber/formatter/rerun_spec.rb +4 -20
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +29 -0
- data/spec/cucumber/runtime_spec.rb +2 -28
- data/spec/spec_helper.rb +1 -1
- data/spec/support/standard_step_actions.rb +18 -0
- metadata +37 -13
- data/lib/cucumber/core_ext/proc.rb +0 -36
- data/spec/cucumber/core_ext/proc_spec.rb +0 -69
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'forwardable'
|
2
|
-
require 'gherkin/
|
2
|
+
require 'cucumber/gherkin/data_table_parser'
|
3
|
+
require 'cucumber/gherkin/formatter/escaping'
|
3
4
|
require 'cucumber/core/ast/describes_itself'
|
4
5
|
|
5
6
|
module Cucumber
|
@@ -37,7 +38,7 @@ module Cucumber
|
|
37
38
|
@rows = []
|
38
39
|
end
|
39
40
|
|
40
|
-
def row(row
|
41
|
+
def row(row)
|
41
42
|
@rows << row
|
42
43
|
end
|
43
44
|
|
@@ -73,8 +74,8 @@ module Cucumber
|
|
73
74
|
private
|
74
75
|
def parse(text, location = Core::Ast::Location.of_caller)
|
75
76
|
builder = Builder.new
|
76
|
-
|
77
|
-
|
77
|
+
parser = Cucumber::Gherkin::DataTableParser.new(builder)
|
78
|
+
parser.parse(text)
|
78
79
|
from_array(builder.rows, location)
|
79
80
|
end
|
80
81
|
|
@@ -639,7 +640,7 @@ module Cucumber
|
|
639
640
|
# Represents a row of cells or columns of cells
|
640
641
|
class Cells #:nodoc:
|
641
642
|
include Enumerable
|
642
|
-
include Gherkin::Formatter::Escaping
|
643
|
+
include Cucumber::Gherkin::Formatter::Escaping
|
643
644
|
|
644
645
|
attr_reader :exception
|
645
646
|
|
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 = '2.0
|
7
|
+
VERSION = '2.1.0'
|
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)
|
data/lib/cucumber/rake/task.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'cucumber/platform'
|
2
|
-
require 'gherkin/formatter/ansi_escapes'
|
2
|
+
require 'cucumber/gherkin/formatter/ansi_escapes'
|
3
3
|
begin
|
4
4
|
# Support Rake > 0.8.7
|
5
5
|
require 'rake/dsl_definition'
|
@@ -25,7 +25,7 @@ module Cucumber
|
|
25
25
|
#
|
26
26
|
# See the attributes for additional configuration possibilities.
|
27
27
|
class Task
|
28
|
-
include Gherkin::Formatter::AnsiEscapes
|
28
|
+
include Cucumber::Gherkin::Formatter::AnsiEscapes
|
29
29
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
30
30
|
|
31
31
|
class InProcessCucumberRunner #:nodoc:
|
@@ -8,12 +8,7 @@ module Cucumber
|
|
8
8
|
@rb_language = rb_language
|
9
9
|
@tag_expressions = tag_expressions
|
10
10
|
@proc = proc
|
11
|
-
|
12
|
-
@location = Core::Ast::Location.new(file, line)
|
13
|
-
end
|
14
|
-
|
15
|
-
def source_location
|
16
|
-
@proc.source_location
|
11
|
+
@location = Cucumber::Core::Ast::Location.from_source_location(*@proc.source_location)
|
17
12
|
end
|
18
13
|
|
19
14
|
def invoke(pseudo_method, arguments, &block)
|
@@ -5,6 +5,7 @@ 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
|
require 'cucumber/rb_support/snippet'
|
8
|
+
require 'cucumber/gherkin/i18n'
|
8
9
|
require 'multi_test'
|
9
10
|
|
10
11
|
module Cucumber
|
@@ -21,8 +22,8 @@ module Cucumber
|
|
21
22
|
def initialize(first_proc, second_proc)
|
22
23
|
message = "You can only pass a proc to #World once, but it's happening\n"
|
23
24
|
message << "in 2 places:\n\n"
|
24
|
-
message <<
|
25
|
-
message <<
|
25
|
+
message << RbSupport.backtrace_line(first_proc, 'World') << "\n"
|
26
|
+
message << RbSupport.backtrace_line(second_proc, 'World') << "\n\n"
|
26
27
|
message << "Use Ruby modules instead to extend your worlds. See the Cucumber::RbSupport::RbDsl#World RDoc\n"
|
27
28
|
message << "or http://wiki.github.com/cucumber/cucumber/a-whole-new-world.\n\n"
|
28
29
|
super(message)
|
@@ -35,8 +36,12 @@ module Cucumber
|
|
35
36
|
attr_reader :current_world,
|
36
37
|
:step_definitions
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
all_keywords = ::Gherkin3::DIALECTS.keys.map do |dialect_name|
|
40
|
+
dialect = ::Gherkin3::Dialect.for(dialect_name)
|
41
|
+
dialect.given_keywords + dialect.when_keywords + dialect.then_keywords + dialect.and_keywords + dialect.but_keywords
|
42
|
+
end
|
43
|
+
Cucumber::Gherkin::I18n.code_keywords_for(all_keywords.flatten.uniq.sort).each do |adverb|
|
44
|
+
RbDsl.alias_adverb(adverb.strip)
|
40
45
|
end
|
41
46
|
|
42
47
|
def initialize(runtime)
|
@@ -132,7 +137,7 @@ module Cucumber
|
|
132
137
|
raise NilWorld.new
|
133
138
|
rescue NilWorld => e
|
134
139
|
e.backtrace.clear
|
135
|
-
e.backtrace.push(
|
140
|
+
e.backtrace.push(RbSupport.backtrace_line(proc, "World"))
|
136
141
|
raise e
|
137
142
|
end
|
138
143
|
else
|
@@ -156,5 +161,10 @@ module Cucumber
|
|
156
161
|
end
|
157
162
|
end
|
158
163
|
end
|
164
|
+
|
165
|
+
def self.backtrace_line(proc, name)
|
166
|
+
location = Cucumber::Core::Ast::Location.from_source_location(*proc.source_location)
|
167
|
+
"#{location.to_s}:in `#{name}'"
|
168
|
+
end
|
159
169
|
end
|
160
170
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'cucumber/step_match'
|
2
2
|
require 'cucumber/core_ext/string'
|
3
|
-
require 'cucumber/core_ext/proc'
|
4
3
|
require 'cucumber/rb_support/regexp_argument_matcher'
|
5
4
|
|
6
5
|
module Cucumber
|
@@ -51,17 +50,8 @@ module Cucumber
|
|
51
50
|
end
|
52
51
|
|
53
52
|
def patch_location_onto(block)
|
54
|
-
|
55
|
-
|
56
|
-
pwd = File.expand_path(Dir.pwd)
|
57
|
-
pwd.force_encoding(file.encoding)
|
58
|
-
if file.index(pwd)
|
59
|
-
file = file[pwd.length+1..-1]
|
60
|
-
elsif file =~ /.*\/gems\/(.*\.rb)$/
|
61
|
-
file = $1
|
62
|
-
end
|
63
|
-
location = Core::Ast::Location.new(file, line)
|
64
|
-
block.define_singleton_method(:file_colon_line) { location.to_s }
|
53
|
+
location = Core::Ast::Location.of_caller(5)
|
54
|
+
block.define_singleton_method(:source_location) { [location.file, location.line] }
|
65
55
|
block
|
66
56
|
end
|
67
57
|
|
@@ -81,7 +71,7 @@ module Cucumber
|
|
81
71
|
|
82
72
|
def initialize(rb_language, regexp, proc)
|
83
73
|
@rb_language, @regexp, @proc = rb_language, regexp, proc
|
84
|
-
@rb_language.available_step_definition(regexp_source,
|
74
|
+
@rb_language.available_step_definition(regexp_source, location)
|
85
75
|
end
|
86
76
|
|
87
77
|
def regexp_source
|
@@ -102,7 +92,7 @@ module Cucumber
|
|
102
92
|
|
103
93
|
def arguments_from(step_name)
|
104
94
|
args = RegexpArgumentMatcher.arguments_from(@regexp, step_name)
|
105
|
-
@rb_language.invoked_step_definition(regexp_source,
|
95
|
+
@rb_language.invoked_step_definition(regexp_source, location) if args
|
106
96
|
args
|
107
97
|
end
|
108
98
|
|
@@ -117,20 +107,24 @@ module Cucumber
|
|
117
107
|
end
|
118
108
|
|
119
109
|
def backtrace_line
|
120
|
-
|
110
|
+
"#{location.to_s}:in `#{regexp_source}'"
|
121
111
|
end
|
122
112
|
|
123
113
|
def file_colon_line
|
124
114
|
case @proc
|
125
115
|
when Proc
|
126
|
-
|
116
|
+
location.to_s
|
127
117
|
when Symbol
|
128
118
|
":#{@proc}"
|
129
119
|
end
|
130
120
|
end
|
131
121
|
|
122
|
+
def location
|
123
|
+
@location ||= Cucumber::Core::Ast::Location.from_source_location(*@proc.source_location)
|
124
|
+
end
|
125
|
+
|
132
126
|
def file
|
133
|
-
@file ||=
|
127
|
+
@file ||= location.file
|
134
128
|
end
|
135
129
|
end
|
136
130
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'gherkin/formatter/ansi_escapes'
|
1
|
+
require 'cucumber/gherkin/formatter/ansi_escapes'
|
2
2
|
|
3
3
|
module Cucumber
|
4
4
|
module RbSupport
|
@@ -9,7 +9,7 @@ module Cucumber
|
|
9
9
|
module RbWorld
|
10
10
|
|
11
11
|
# @private
|
12
|
-
AnsiEscapes = Gherkin::Formatter::AnsiEscapes
|
12
|
+
AnsiEscapes = Cucumber::Gherkin::Formatter::AnsiEscapes
|
13
13
|
|
14
14
|
# Call a Transform with a string from another Transform definition
|
15
15
|
def Transform(arg)
|
@@ -48,7 +48,8 @@ module Cucumber
|
|
48
48
|
# }
|
49
49
|
# @param [String] steps_text The Gherkin snippet to run
|
50
50
|
def steps(steps_text)
|
51
|
-
|
51
|
+
location = Core::Ast::Location.of_caller
|
52
|
+
@__cucumber_runtime.invoke_dynamic_steps(steps_text, @__natural_language, location)
|
52
53
|
end
|
53
54
|
|
54
55
|
# Parse Gherkin into a {Cucumber::Ast::Table} object.
|
@@ -74,6 +75,7 @@ module Cucumber
|
|
74
75
|
# puts "this is ruby code"
|
75
76
|
# %}, 'ruby')
|
76
77
|
def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
|
78
|
+
STDERR.puts AnsiEscapes.failed + "WARNING: #doc_string is deprecated. Just pass a regular String instead:" + caller[0] + AnsiEscapes.reset
|
77
79
|
# TODO: rename this method to multiline_string
|
78
80
|
@__cucumber_runtime.doc_string(string_without_triple_quotes, content_type, line_offset)
|
79
81
|
end
|
@@ -89,7 +91,7 @@ module Cucumber
|
|
89
91
|
# @note Cucumber might surprise you with the behaviour of this method. Instead
|
90
92
|
# of sending the output directly to STDOUT, Cucumber will intercept and cache
|
91
93
|
# the message until the current step has finished, and then display it.
|
92
|
-
#
|
94
|
+
#
|
93
95
|
# If you'd prefer to see the message immediately, call {Kernel.puts} instead.
|
94
96
|
def puts(*messages)
|
95
97
|
@__cucumber_runtime.puts(*messages)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'gherkin/formatter/argument'
|
1
|
+
require 'cucumber/gherkin/formatter/argument'
|
2
2
|
|
3
3
|
module Cucumber
|
4
4
|
module RbSupport
|
@@ -10,7 +10,7 @@ module Cucumber
|
|
10
10
|
match.captures.map do |val|
|
11
11
|
n += 1
|
12
12
|
offset = match.offset(n)[0]
|
13
|
-
Gherkin::Formatter::Argument.new(offset, val)
|
13
|
+
Cucumber::Gherkin::Formatter::Argument.new(offset, val)
|
14
14
|
end
|
15
15
|
else
|
16
16
|
nil
|
data/lib/cucumber/runtime.rb
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'multi_json'
|
4
4
|
require 'multi_test'
|
5
|
-
require 'gherkin/rubify'
|
6
|
-
require 'gherkin/i18n'
|
7
5
|
require 'cucumber/configuration'
|
8
6
|
require 'cucumber/load_path'
|
9
7
|
require 'cucumber/language_support/language_methods'
|
@@ -11,6 +9,8 @@ require 'cucumber/formatter/duration'
|
|
11
9
|
require 'cucumber/file_specs'
|
12
10
|
require 'cucumber/filters'
|
13
11
|
require 'cucumber/formatter/fanout'
|
12
|
+
require 'cucumber/formatter/event_bus_report'
|
13
|
+
require 'cucumber/gherkin/i18n'
|
14
14
|
|
15
15
|
module Cucumber
|
16
16
|
module FixRuby21Bug9285
|
@@ -46,14 +46,14 @@ module Cucumber
|
|
46
46
|
include Runtime::UserInterface
|
47
47
|
|
48
48
|
def initialize(configuration = Configuration.default)
|
49
|
-
@configuration = Configuration.
|
49
|
+
@configuration = Configuration.new(configuration)
|
50
50
|
@support_code = SupportCode.new(self, @configuration)
|
51
51
|
@results = Formatter::LegacyApi::Results.new
|
52
52
|
end
|
53
53
|
|
54
54
|
# Allows you to take an existing runtime and change its configuration
|
55
55
|
def configure(new_configuration)
|
56
|
-
@configuration = Configuration.
|
56
|
+
@configuration = Configuration.new(new_configuration)
|
57
57
|
@support_code.configure(@configuration)
|
58
58
|
end
|
59
59
|
|
@@ -86,16 +86,12 @@ module Cucumber
|
|
86
86
|
@results.steps(status)
|
87
87
|
end
|
88
88
|
|
89
|
-
def step_match(step_name, name_to_report=nil) #:nodoc:
|
90
|
-
@support_code.step_match(step_name, name_to_report)
|
91
|
-
end
|
92
|
-
|
93
89
|
def unmatched_step_definitions
|
94
90
|
@support_code.unmatched_step_definitions
|
95
91
|
end
|
96
92
|
|
97
93
|
def snippet_text(step_keyword, step_name, multiline_arg) #:nodoc:
|
98
|
-
@support_code.snippet_text(::Gherkin::I18n.code_keyword_for(step_keyword), step_name, multiline_arg)
|
94
|
+
@support_code.snippet_text(Cucumber::Gherkin::I18n.code_keyword_for(step_keyword).strip, step_name, multiline_arg)
|
99
95
|
end
|
100
96
|
|
101
97
|
def begin_scenario(scenario)
|
@@ -180,26 +176,50 @@ module Cucumber
|
|
180
176
|
require 'cucumber/formatter/legacy_api/runtime_facade'
|
181
177
|
require 'cucumber/formatter/legacy_api/results'
|
182
178
|
require 'cucumber/formatter/ignore_missing_messages'
|
179
|
+
require 'cucumber/formatter/fail_fast'
|
183
180
|
require 'cucumber/core/report/summary'
|
184
181
|
def report
|
185
|
-
@report
|
182
|
+
return @report if @report
|
183
|
+
reports = [summary_report, event_bus_report] + formatters
|
184
|
+
reports << fail_fast_report if @configuration.fail_fast?
|
185
|
+
@report ||= Formatter::Fanout.new(reports)
|
186
186
|
end
|
187
187
|
|
188
188
|
def summary_report
|
189
189
|
@summary_report ||= Core::Report::Summary.new
|
190
190
|
end
|
191
191
|
|
192
|
+
def event_bus_report
|
193
|
+
@event_bus_report ||= Formatter::EventBusReport.new(@configuration)
|
194
|
+
end
|
195
|
+
|
196
|
+
def fail_fast_report
|
197
|
+
@fail_fast_report ||= Formatter::FailFast.new(@configuration)
|
198
|
+
end
|
199
|
+
|
192
200
|
def formatters
|
193
201
|
@formatters ||= @configuration.formatter_factories { |factory, path_or_io, options|
|
194
|
-
|
195
|
-
runtime_facade = Formatter::LegacyApi::RuntimeFacade.new(results, @support_code, @configuration)
|
196
|
-
formatter = factory.new(runtime_facade, path_or_io, options)
|
197
|
-
Formatter::LegacyApi::Adapter.new(
|
198
|
-
Formatter::IgnoreMissingMessages.new(formatter),
|
199
|
-
results, @support_code, @configuration)
|
202
|
+
create_formatter(factory, path_or_io, options)
|
200
203
|
}
|
201
204
|
end
|
202
205
|
|
206
|
+
def create_formatter(factory, path_or_io, options)
|
207
|
+
if !legacy_formatter?(factory)
|
208
|
+
out_stream = Cucumber::Formatter::Io.ensure_io(path_or_io)
|
209
|
+
return factory.new(@configuration.with_options(out_stream: out_stream))
|
210
|
+
end
|
211
|
+
results = Formatter::LegacyApi::Results.new
|
212
|
+
runtime_facade = Formatter::LegacyApi::RuntimeFacade.new(results, @support_code, @configuration)
|
213
|
+
formatter = factory.new(runtime_facade, path_or_io, options)
|
214
|
+
Formatter::LegacyApi::Adapter.new(
|
215
|
+
Formatter::IgnoreMissingMessages.new(formatter),
|
216
|
+
results, @support_code, @configuration)
|
217
|
+
end
|
218
|
+
|
219
|
+
def legacy_formatter?(factory)
|
220
|
+
factory.instance_method(:initialize).arity > 1
|
221
|
+
end
|
222
|
+
|
203
223
|
def failure?
|
204
224
|
if @configuration.wip?
|
205
225
|
summary_report.test_cases.total_passed > 0
|
@@ -3,6 +3,8 @@ require 'cucumber/runtime/for_programming_languages'
|
|
3
3
|
require 'cucumber/runtime/step_hooks'
|
4
4
|
require 'cucumber/runtime/before_hooks'
|
5
5
|
require 'cucumber/runtime/after_hooks'
|
6
|
+
require 'cucumber/events/step_match'
|
7
|
+
require 'cucumber/gherkin/steps_parser'
|
6
8
|
|
7
9
|
module Cucumber
|
8
10
|
|
@@ -12,28 +14,29 @@ module Cucumber
|
|
12
14
|
|
13
15
|
require 'forwardable'
|
14
16
|
class StepInvoker
|
15
|
-
include Gherkin::Rubify
|
16
17
|
|
17
18
|
def initialize(support_code)
|
18
19
|
@support_code = support_code
|
19
20
|
end
|
20
21
|
|
21
|
-
def
|
22
|
+
def steps(steps)
|
23
|
+
steps.each { |step| step(step) }
|
22
24
|
end
|
23
25
|
|
24
26
|
def step(step)
|
25
27
|
location = Core::Ast::Location.of_caller
|
26
|
-
@support_code.invoke_dynamic_step(step
|
27
|
-
end
|
28
|
-
|
29
|
-
def eof
|
28
|
+
@support_code.invoke_dynamic_step(step[:text], multiline_arg(step, location))
|
30
29
|
end
|
31
30
|
|
32
31
|
def multiline_arg(step, location)
|
33
|
-
if argument = step
|
34
|
-
|
32
|
+
if argument = step[:argument]
|
33
|
+
if argument[:type] == :DocString
|
34
|
+
MultilineArgument.doc_string(argument[:content], argument[:content_type], location)
|
35
|
+
else
|
36
|
+
MultilineArgument::DataTable.from(argument[:rows].map { |row| row[:cells].map { |cell| cell[:value] } })
|
37
|
+
end
|
35
38
|
else
|
36
|
-
MultilineArgument.from(
|
39
|
+
MultilineArgument.from(nil)
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -41,7 +44,7 @@ module Cucumber
|
|
41
44
|
include Constantize
|
42
45
|
|
43
46
|
def initialize(user_interface, configuration={})
|
44
|
-
@configuration = Configuration.
|
47
|
+
@configuration = Configuration.new(configuration)
|
45
48
|
@runtime_facade = Runtime::ForProgrammingLanguages.new(self, user_interface)
|
46
49
|
@unsupported_programming_languages = []
|
47
50
|
@programming_languages = []
|
@@ -49,7 +52,7 @@ module Cucumber
|
|
49
52
|
end
|
50
53
|
|
51
54
|
def configure(new_configuration)
|
52
|
-
@configuration = Configuration.
|
55
|
+
@configuration = Configuration.new(new_configuration)
|
53
56
|
end
|
54
57
|
|
55
58
|
# Invokes a series of steps +steps_text+. Example:
|
@@ -58,10 +61,9 @@ module Cucumber
|
|
58
61
|
# Given I have 8 cukes in my belly
|
59
62
|
# Then I should not be thirsty
|
60
63
|
# })
|
61
|
-
def invoke_dynamic_steps(steps_text, i18n,
|
62
|
-
|
63
|
-
parser
|
64
|
-
parser.parse(steps_text, file, line.to_i)
|
64
|
+
def invoke_dynamic_steps(steps_text, i18n, location)
|
65
|
+
parser = Cucumber::Gherkin::StepsParser.new(StepInvoker.new(self), i18n.iso_code)
|
66
|
+
parser.parse(steps_text)
|
65
67
|
end
|
66
68
|
|
67
69
|
# @api private
|
@@ -139,6 +141,8 @@ module Cucumber
|
|
139
141
|
rescue Cucumber::Undefined
|
140
142
|
return NoStepMatch.new(test_step.source.last, test_step.name)
|
141
143
|
end
|
144
|
+
# TODO: move this onto Filters::ActivateSteps
|
145
|
+
@configuration.notify Events::StepMatch.new(test_step, match)
|
142
146
|
if @configuration.dry_run?
|
143
147
|
return SkippingStepMatch.new
|
144
148
|
end
|