cucumber 1.2.5 → 1.3.0
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.
- checksums.yaml +14 -6
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -0
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +2 -2
- data/History.md +38 -2
- data/bin/cucumber +2 -11
- data/cucumber.gemspec +3 -3
- data/cucumber.yml +5 -1
- data/examples/test_unit/Gemfile +4 -0
- data/examples/test_unit/features/step_definitions/test_unit_steps.rb +1 -4
- data/examples/watir/README.textile +2 -2
- data/examples/watir/features/support/env.rb +10 -7
- data/features/.cucumber/stepdefs.json +747 -1354
- data/features/assertions.feature +6 -2
- data/features/background.feature +3 -0
- data/features/backtraces.feature +3 -3
- data/features/before_hook.feature +43 -0
- data/features/bootstrap.feature +14 -2
- data/features/custom_formatter.feature +1 -1
- data/features/drb_server_integration.feature +3 -3
- data/features/formatter_callbacks.feature +2 -2
- data/features/formatter_step_file_colon_line.feature +1 -1
- data/features/html_formatter.feature +52 -1
- data/features/json_formatter.feature +93 -7
- data/features/load_path.feature +14 -0
- data/features/nested_steps.feature +75 -3
- data/features/nested_steps_i18n.feature +36 -0
- data/features/pretty_formatter.feature +31 -0
- data/features/progress_formatter.feature +31 -0
- data/features/raketask.feature +51 -0
- data/features/rerun_formatter.feature +1 -1
- data/features/stats_formatters.feature +17 -14
- data/features/step_definitions/cucumber_steps.rb +6 -4
- data/features/support/env.rb +31 -4
- data/features/support/feature_factory.rb +17 -0
- data/features/tagged_hooks.feature +37 -195
- data/features/transforms.feature +15 -15
- data/gem_tasks/cucumber.rake +2 -0
- data/gem_tasks/yard.rake +10 -6
- data/legacy_features/README.md +14 -0
- data/legacy_features/language_help.feature +3 -1
- data/legacy_features/report_called_undefined_steps.feature +1 -0
- data/legacy_features/snippets_when_using_star_keyword.feature +1 -0
- data/legacy_features/support/env.rb +4 -0
- data/lib/cucumber/ast/background.rb +35 -35
- data/lib/cucumber/ast/empty_background.rb +33 -0
- data/lib/cucumber/ast/examples.rb +5 -2
- data/lib/cucumber/ast/feature.rb +24 -35
- data/lib/cucumber/ast/features.rb +4 -1
- data/lib/cucumber/ast/has_steps.rb +9 -17
- data/lib/cucumber/ast/location.rb +41 -0
- data/lib/cucumber/ast/scenario.rb +37 -50
- data/lib/cucumber/ast/scenario_outline.rb +62 -49
- data/lib/cucumber/ast/step.rb +23 -27
- data/lib/cucumber/ast/step_collection.rb +16 -0
- data/lib/cucumber/ast/step_invocation.rb +4 -1
- data/lib/cucumber/ast/tree_walker.rb +7 -0
- data/lib/cucumber/cli/configuration.rb +15 -3
- data/lib/cucumber/cli/main.rb +24 -11
- data/lib/cucumber/cli/options.rb +24 -16
- data/lib/cucumber/configuration.rb +4 -0
- data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +10 -34
- data/lib/cucumber/core_ext/instance_exec.rb +4 -1
- data/lib/cucumber/core_ext/proc.rb +2 -0
- data/lib/cucumber/feature_file.rb +5 -12
- data/lib/cucumber/formatter/console.rb +10 -0
- data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +4 -4
- data/lib/cucumber/formatter/html.rb +7 -42
- data/lib/cucumber/formatter/interceptor.rb +4 -0
- data/lib/cucumber/formatter/json_pretty.rb +0 -4
- data/lib/cucumber/formatter/junit.rb +8 -2
- data/lib/cucumber/formatter/pretty.rb +5 -1
- data/lib/cucumber/formatter/progress.rb +4 -0
- data/lib/cucumber/formatter/unicode.rb +12 -25
- data/lib/cucumber/formatter/usage.rb +7 -2
- data/lib/cucumber/js_support/js_snippets.rb +1 -1
- data/lib/cucumber/load_path.rb +13 -0
- data/lib/cucumber/parser/gherkin_builder.rb +237 -81
- data/lib/cucumber/platform.rb +1 -1
- data/lib/cucumber/py_support/py_language.rb +1 -1
- data/lib/cucumber/rake/task.rb +5 -1
- data/lib/cucumber/rb_support/rb_language.rb +20 -19
- data/lib/cucumber/rb_support/rb_world.rb +63 -21
- data/lib/cucumber/rb_support/snippet.rb +108 -0
- data/lib/cucumber/runtime.rb +1 -0
- data/lib/cucumber/runtime/support_code.rb +2 -2
- data/lib/cucumber/unit.rb +11 -0
- data/lib/cucumber/wire_support/wire_language.rb +1 -1
- data/spec/cucumber/ast/background_spec.rb +13 -6
- data/spec/cucumber/ast/feature_factory.rb +20 -10
- data/spec/cucumber/ast/features_spec.rb +51 -0
- data/spec/cucumber/ast/scenario_outline_spec.rb +13 -7
- data/spec/cucumber/ast/step_spec.rb +6 -4
- data/spec/cucumber/cli/configuration_spec.rb +34 -1
- data/spec/cucumber/cli/main_spec.rb +36 -26
- data/spec/cucumber/cli/options_spec.rb +28 -19
- data/spec/cucumber/core_ext/proc_spec.rb +13 -1
- data/spec/cucumber/formatter/interceptor_spec.rb +8 -0
- data/spec/cucumber/formatter/junit_spec.rb +33 -0
- data/spec/cucumber/formatter/pretty_spec.rb +391 -0
- data/spec/cucumber/rb_support/rb_language_spec.rb +21 -50
- data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +2 -4
- data/spec/cucumber/rb_support/snippet_spec.rb +128 -0
- data/spec/cucumber/step_match_spec.rb +2 -6
- metadata +62 -113
- data/.rvmrc +0 -1
- data/features/hooks.feature +0 -59
- data/legacy_features/call_steps_from_stepdefs.feature +0 -154
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.
|
|
7
|
+
VERSION = '1.3.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)
|
|
@@ -24,7 +24,7 @@ module Cucumber
|
|
|
24
24
|
def alias_adverbs(adverbs)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def snippet_text(code_keyword, step_name, multiline_arg_class)
|
|
27
|
+
def snippet_text(code_keyword, step_name, multiline_arg_class, snippet_type)
|
|
28
28
|
"python snippet: #{code_keyword}, #{step_name}"
|
|
29
29
|
end
|
|
30
30
|
|
data/lib/cucumber/rake/task.rb
CHANGED
|
@@ -4,6 +4,7 @@ require 'cucumber/rb_support/rb_world'
|
|
|
4
4
|
require 'cucumber/rb_support/rb_step_definition'
|
|
5
5
|
require 'cucumber/rb_support/rb_hook'
|
|
6
6
|
require 'cucumber/rb_support/rb_transform'
|
|
7
|
+
require 'cucumber/rb_support/snippet'
|
|
7
8
|
|
|
8
9
|
begin
|
|
9
10
|
require 'rspec/expectations'
|
|
@@ -83,25 +84,9 @@ module Cucumber
|
|
|
83
84
|
end.compact
|
|
84
85
|
end
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
snippet_pattern = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
|
|
90
|
-
arg_count = 0
|
|
91
|
-
ARGUMENT_PATTERNS.each do |pattern|
|
|
92
|
-
snippet_pattern = snippet_pattern.gsub(Regexp.new(pattern), pattern)
|
|
93
|
-
arg_count += snippet_pattern.scan(pattern).length
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
block_args = (0...arg_count).map {|n| "arg#{n+1}"}
|
|
97
|
-
block_args << multiline_arg_class.default_arg_name unless multiline_arg_class.nil?
|
|
98
|
-
block_arg_string = block_args.empty? ? "" : " |#{block_args.join(", ")}|"
|
|
99
|
-
multiline_class_comment = ""
|
|
100
|
-
if(multiline_arg_class == Ast::Table)
|
|
101
|
-
multiline_class_comment = "# #{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n "
|
|
102
|
-
end
|
|
103
|
-
|
|
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"
|
|
87
|
+
def snippet_text(code_keyword, step_name, multiline_arg_class, snippet_type = :regexp)
|
|
88
|
+
snippet_class = typed_snippet_class(snippet_type)
|
|
89
|
+
snippet_class.new(code_keyword, step_name, multiline_arg_class).to_s
|
|
105
90
|
end
|
|
106
91
|
|
|
107
92
|
def begin_rb_scenario(scenario)
|
|
@@ -184,6 +169,22 @@ module Cucumber
|
|
|
184
169
|
o
|
|
185
170
|
end
|
|
186
171
|
end
|
|
172
|
+
|
|
173
|
+
SNIPPET_TYPES = {
|
|
174
|
+
:regexp => Snippet::Regexp,
|
|
175
|
+
:classic => Snippet::Classic,
|
|
176
|
+
:percent => Snippet::Percent
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
def typed_snippet_class(type)
|
|
180
|
+
SNIPPET_TYPES.fetch(type || :regexp)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def self.cli_snippet_type_options
|
|
184
|
+
SNIPPET_TYPES.keys.sort_by(&:to_s).map do |type|
|
|
185
|
+
SNIPPET_TYPES[type].cli_option_string(type)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
187
188
|
end
|
|
188
189
|
end
|
|
189
190
|
end
|
|
@@ -2,11 +2,17 @@ require 'gherkin/formatter/ansi_escapes'
|
|
|
2
2
|
|
|
3
3
|
module Cucumber
|
|
4
4
|
module RbSupport
|
|
5
|
-
#
|
|
5
|
+
# Defines the basic DSL methods availlable in all Cucumber step definitions.
|
|
6
|
+
#
|
|
7
|
+
# You can, and probably should, extend this DSL with your own methods that
|
|
8
|
+
# make sense in your domain. For more on that, see {Cucumber::RbSupport::RbDsl#World}
|
|
6
9
|
module RbWorld
|
|
10
|
+
|
|
11
|
+
# @private
|
|
7
12
|
AnsiEscapes = Gherkin::Formatter::AnsiEscapes
|
|
8
13
|
|
|
9
14
|
class << self
|
|
15
|
+
# @private
|
|
10
16
|
def alias_adverb(adverb)
|
|
11
17
|
alias_method adverb, :__cucumber_invoke
|
|
12
18
|
end
|
|
@@ -18,49 +24,95 @@ module Cucumber
|
|
|
18
24
|
rb.execute_transforms([arg]).first
|
|
19
25
|
end
|
|
20
26
|
|
|
27
|
+
# @private
|
|
21
28
|
attr_writer :__cucumber_runtime, :__natural_language
|
|
22
29
|
|
|
30
|
+
# @private
|
|
23
31
|
def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
|
|
24
32
|
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
33
|
@__cucumber_runtime.invoke(name, multiline_argument)
|
|
26
34
|
end
|
|
27
35
|
|
|
28
|
-
#
|
|
36
|
+
# Run a single Gherkin step
|
|
37
|
+
# @example Call another step
|
|
38
|
+
# step "I am logged in"
|
|
39
|
+
# @example Call a step with quotes in the name
|
|
40
|
+
# step %{the user "Dave" is logged in}
|
|
41
|
+
# @example Passing a table
|
|
42
|
+
# step "the following users exist:", table(%{
|
|
43
|
+
# | name | email |
|
|
44
|
+
# | Matt | matt@matt.com |
|
|
45
|
+
# | Aslak | aslak@aslak.com |
|
|
46
|
+
# })
|
|
47
|
+
# @example Passing a multiline string
|
|
48
|
+
# step "the email should contain:", "Dear sir,\nYou've won a prize!\n"
|
|
49
|
+
# @param [String] name The name of the step
|
|
50
|
+
# @param [String,Cucumber::Ast::DocString,Cucumber::Ast::Table] multiline_argument
|
|
29
51
|
def step(name, multiline_argument=nil)
|
|
30
52
|
@__cucumber_runtime.invoke(name, multiline_argument)
|
|
31
53
|
end
|
|
32
54
|
|
|
33
|
-
#
|
|
55
|
+
# Run a snippet of Gherkin
|
|
56
|
+
# @example
|
|
57
|
+
# steps %{
|
|
58
|
+
# Given the user "Susan" exists
|
|
59
|
+
# And I am logged in as "Susan"
|
|
60
|
+
# }
|
|
61
|
+
# @param [String] steps_text The Gherkin snippet to run
|
|
34
62
|
def steps(steps_text)
|
|
35
63
|
@__cucumber_runtime.invoke_steps(steps_text, @__natural_language, caller[0])
|
|
36
64
|
end
|
|
37
65
|
|
|
38
|
-
#
|
|
66
|
+
# Parse Gherkin into a {Cucumber::Ast::Table} object.
|
|
67
|
+
#
|
|
68
|
+
# Useful in conjunction with the #step method.
|
|
69
|
+
# @example Create a table
|
|
70
|
+
# users = table(%{
|
|
71
|
+
# | name | email |
|
|
72
|
+
# | Matt | matt@matt.com |
|
|
73
|
+
# | Aslak | aslak@aslak.com |
|
|
74
|
+
# })
|
|
75
|
+
# @param [String] text_or_table The Gherkin string that represents the table
|
|
39
76
|
def table(text_or_table, file=nil, line_offset=0)
|
|
40
77
|
@__cucumber_runtime.table(text_or_table, file, line_offset)
|
|
41
78
|
end
|
|
42
79
|
|
|
43
|
-
#
|
|
80
|
+
# Create an {Cucumber::Ast::DocString} object
|
|
81
|
+
#
|
|
82
|
+
# Useful in conjunction with the #step method, when
|
|
83
|
+
# want to specify a content type.
|
|
84
|
+
# @example Create a multiline string
|
|
85
|
+
# code = multiline_string(%{
|
|
86
|
+
# puts "this is ruby code"
|
|
87
|
+
# %}, 'ruby')
|
|
44
88
|
def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
|
|
89
|
+
# TODO: rename this method to multiline_string
|
|
45
90
|
@__cucumber_runtime.doc_string(string_without_triple_quotes, content_type, line_offset)
|
|
46
91
|
end
|
|
47
92
|
|
|
93
|
+
# @deprecated Use {#puts} instead.
|
|
48
94
|
def announce(*messages)
|
|
49
95
|
STDERR.puts AnsiEscapes.failed + "WARNING: #announce is deprecated. Use #puts instead:" + caller[0] + AnsiEscapes.reset
|
|
50
96
|
puts(*messages)
|
|
51
97
|
end
|
|
52
98
|
|
|
53
|
-
#
|
|
99
|
+
# Print a message to the output.
|
|
100
|
+
#
|
|
101
|
+
# @note Cucumber might surprise you with the behaviour of this method. Instead
|
|
102
|
+
# of sending the output directly to STDOUT, Cucumber will intercept and cache
|
|
103
|
+
# the message until the current step has finished, and then display it.
|
|
104
|
+
#
|
|
105
|
+
# If you'd prefer to see the message immediately, call {Kernel#puts} instead.
|
|
54
106
|
def puts(*messages)
|
|
55
107
|
@__cucumber_runtime.puts(*messages)
|
|
56
108
|
end
|
|
57
109
|
|
|
58
|
-
#
|
|
110
|
+
# Pause the tests and ask the operator for input
|
|
59
111
|
def ask(question, timeout_seconds=60)
|
|
60
112
|
@__cucumber_runtime.ask(question, timeout_seconds)
|
|
61
113
|
end
|
|
62
114
|
|
|
63
|
-
#
|
|
115
|
+
# Embed an image in the output
|
|
64
116
|
def embed(file, mime_type, label='Screenshot')
|
|
65
117
|
@__cucumber_runtime.embed(file, mime_type, label)
|
|
66
118
|
end
|
|
@@ -79,19 +131,8 @@ module Cucumber
|
|
|
79
131
|
end
|
|
80
132
|
end
|
|
81
133
|
|
|
82
|
-
#
|
|
83
|
-
|
|
84
|
-
# This can be time consuming if the object graph is large.
|
|
85
|
-
#
|
|
86
|
-
# This can cause unnecessary delays when certain exceptions
|
|
87
|
-
# occur. For example, MRI internally invokes #inspect on an
|
|
88
|
-
# object that raises a NoMethodError. (JRuby does not do this).
|
|
89
|
-
#
|
|
90
|
-
# A World object can have many references created by the user
|
|
91
|
-
# or frameworks (Rails), so to avoid long waiting times on
|
|
92
|
-
# such errors in World we define it to just return a simple String.
|
|
93
|
-
#
|
|
94
|
-
def inspect #:nodoc:
|
|
134
|
+
# Prints the list of modules that are included in the World
|
|
135
|
+
def inspect
|
|
95
136
|
modules = [self.class]
|
|
96
137
|
(class << self; self; end).instance_eval do
|
|
97
138
|
modules += included_modules
|
|
@@ -99,6 +140,7 @@ module Cucumber
|
|
|
99
140
|
sprintf("#<%s:0x%x>", modules.join('+'), self.object_id)
|
|
100
141
|
end
|
|
101
142
|
|
|
143
|
+
# see {#inspect}
|
|
102
144
|
def to_s
|
|
103
145
|
inspect
|
|
104
146
|
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
module Cucumber
|
|
2
|
+
module RbSupport
|
|
3
|
+
module Snippet
|
|
4
|
+
|
|
5
|
+
ARGUMENT_PATTERNS = ['"(.*?)"', '(\d+)']
|
|
6
|
+
|
|
7
|
+
class BaseSnippet
|
|
8
|
+
|
|
9
|
+
def initialize(code_keyword, pattern, multiline_argument_class)
|
|
10
|
+
@number_of_arguments = 0
|
|
11
|
+
@code_keyword = code_keyword
|
|
12
|
+
@pattern = replace_and_count_capturing_groups(pattern)
|
|
13
|
+
@multiline_argument_class = multiline_argument_class
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_s
|
|
17
|
+
"#{step} #{do_block}"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def step
|
|
21
|
+
"#{code_keyword}#{typed_pattern}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.cli_option_string(type)
|
|
25
|
+
"%-7s: %-28s e.g. %s" % [type, description, example]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
attr_reader :code_keyword, :pattern, :multiline_argument_class, :number_of_arguments
|
|
31
|
+
|
|
32
|
+
def replace_and_count_capturing_groups(pattern)
|
|
33
|
+
modified_pattern = ::Regexp.escape(pattern).gsub('\ ', ' ').gsub('/', '\/')
|
|
34
|
+
|
|
35
|
+
ARGUMENT_PATTERNS.each do |argument_pattern|
|
|
36
|
+
modified_pattern.gsub!(::Regexp.new(argument_pattern), argument_pattern)
|
|
37
|
+
@number_of_arguments += modified_pattern.scan(argument_pattern).length
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
modified_pattern
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def do_block
|
|
44
|
+
do_block = ""
|
|
45
|
+
do_block << "do#{arguments}\n"
|
|
46
|
+
do_block << multiline_comment if multiline_argument_class?
|
|
47
|
+
do_block << " pending # express the regexp above with the code you wish you had\n"
|
|
48
|
+
do_block << "end"
|
|
49
|
+
do_block
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def arguments
|
|
53
|
+
block_args = (0...number_of_arguments).map { |n| "arg#{n+1}" }
|
|
54
|
+
|
|
55
|
+
if multiline_argument_class
|
|
56
|
+
block_args << multiline_argument_class.default_arg_name
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
block_args.empty? ? "" : " |#{block_args.join(", ")}|"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def multiline_comment
|
|
63
|
+
" # #{multiline_argument_class.default_arg_name} is a #{multiline_argument_class.to_s}\n"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def multiline_argument_class?
|
|
67
|
+
multiline_argument_class == Ast::Table
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.example
|
|
71
|
+
new("Given", "missing step", nil).step
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
class Regexp < BaseSnippet
|
|
77
|
+
def typed_pattern
|
|
78
|
+
"(/^#{pattern}$/)"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.description
|
|
82
|
+
"Snippets with parentheses"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
class Classic < BaseSnippet
|
|
87
|
+
def typed_pattern
|
|
88
|
+
" /^#{pattern}$/"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def self.description
|
|
92
|
+
"Snippets without parentheses. Note that these cause a warning from modern versions of Ruby."
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
class Percent < BaseSnippet
|
|
97
|
+
def typed_pattern
|
|
98
|
+
" %r{^#{pattern}$}"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def self.description
|
|
102
|
+
"Snippets with percent regexp"
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
data/lib/cucumber/runtime.rb
CHANGED
|
@@ -3,6 +3,7 @@ require 'multi_json'
|
|
|
3
3
|
require 'gherkin/rubify'
|
|
4
4
|
require 'gherkin/i18n'
|
|
5
5
|
require 'cucumber/configuration'
|
|
6
|
+
require 'cucumber/load_path'
|
|
6
7
|
require 'cucumber/language_support/language_methods'
|
|
7
8
|
require 'cucumber/formatter/duration'
|
|
8
9
|
require 'cucumber/runtime/user_interface'
|
|
@@ -49,7 +49,7 @@ module Cucumber
|
|
|
49
49
|
# })
|
|
50
50
|
def invoke_steps(steps_text, i18n, file_colon_line)
|
|
51
51
|
file, line = file_colon_line.split(':')
|
|
52
|
-
parser = Gherkin::Parser::Parser.new(StepInvoker.new(self), true, 'steps')
|
|
52
|
+
parser = Gherkin::Parser::Parser.new(StepInvoker.new(self), true, 'steps', false, i18n.iso_code)
|
|
53
53
|
parser.parse(steps_text, file, line.to_i)
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -99,7 +99,7 @@ module Cucumber
|
|
|
99
99
|
def snippet_text(step_keyword, step_name, multiline_arg_class) #:nodoc:
|
|
100
100
|
load_programming_language('rb') if unknown_programming_language?
|
|
101
101
|
@programming_languages.map do |programming_language|
|
|
102
|
-
programming_language.snippet_text(step_keyword, step_name, multiline_arg_class)
|
|
102
|
+
programming_language.snippet_text(step_keyword, step_name, multiline_arg_class, @configuration.snippet_type)
|
|
103
103
|
end.join("\n")
|
|
104
104
|
end
|
|
105
105
|
|
|
@@ -26,7 +26,7 @@ module Cucumber
|
|
|
26
26
|
@connections << Connection.new(config)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def snippet_text(code_keyword, step_name, multiline_arg_class)
|
|
29
|
+
def snippet_text(code_keyword, step_name, multiline_arg_class, snippet_type)
|
|
30
30
|
snippets = @connections.map do |remote|
|
|
31
31
|
remote.snippet_text(code_keyword, step_name, multiline_arg_class.to_s)
|
|
32
32
|
end
|
|
@@ -5,6 +5,7 @@ require 'cucumber/rb_support/rb_language'
|
|
|
5
5
|
module Cucumber
|
|
6
6
|
module Ast
|
|
7
7
|
describe Background do
|
|
8
|
+
let(:language) { stub.as_null_object }
|
|
8
9
|
|
|
9
10
|
before do
|
|
10
11
|
extend(Cucumber::RbSupport::RbDsl)
|
|
@@ -21,24 +22,27 @@ module Cucumber
|
|
|
21
22
|
|
|
22
23
|
@visitor = TreeWalker.new(@runtime)
|
|
23
24
|
|
|
24
|
-
@feature = mock('feature', :visit? => true).as_null_object
|
|
25
|
+
@feature = mock('feature', :visit? => true, :feature_elements => []).as_null_object
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
it "should execute Before blocks before background steps" do
|
|
28
29
|
background = Background.new(
|
|
30
|
+
language,
|
|
31
|
+
Location.new('foo.feature', 2),
|
|
29
32
|
comment=Comment.new(''),
|
|
30
|
-
line=2,
|
|
31
33
|
keyword="",
|
|
32
34
|
title="",
|
|
33
35
|
description="",
|
|
34
36
|
steps=[
|
|
35
|
-
Step.new(7, "Given", "y is 5")
|
|
37
|
+
Step.new(language,Location.new('foo.feature', 7), "Given", "y is 5")
|
|
36
38
|
])
|
|
37
39
|
|
|
38
40
|
scenario = Scenario.new(
|
|
41
|
+
language,
|
|
39
42
|
background,
|
|
40
43
|
comment=Comment.new(""),
|
|
41
44
|
tags=Tags.new(98,[]),
|
|
45
|
+
feature_tags=Tags.new(1,[]),
|
|
42
46
|
line=99,
|
|
43
47
|
keyword="",
|
|
44
48
|
title="",
|
|
@@ -54,8 +58,9 @@ module Cucumber
|
|
|
54
58
|
describe "should respond to #name" do
|
|
55
59
|
it "with a value" do
|
|
56
60
|
background = Background.new(
|
|
61
|
+
language,
|
|
62
|
+
Location.new('foo.feature', 2),
|
|
57
63
|
comment=Comment.new(''),
|
|
58
|
-
line=2,
|
|
59
64
|
keyword="",
|
|
60
65
|
title="background name",
|
|
61
66
|
description="",
|
|
@@ -65,6 +70,7 @@ module Cucumber
|
|
|
65
70
|
end
|
|
66
71
|
it "without a value" do
|
|
67
72
|
background = Background.new(
|
|
73
|
+
language,
|
|
68
74
|
comment=Comment.new(''),
|
|
69
75
|
line=2,
|
|
70
76
|
keyword="",
|
|
@@ -86,13 +92,14 @@ module Cucumber
|
|
|
86
92
|
it "should state that the background has failed" do
|
|
87
93
|
# Assign
|
|
88
94
|
background = Background.new(
|
|
95
|
+
language,
|
|
96
|
+
Location.new('foo.feature', 2),
|
|
89
97
|
comment=Comment.new(''),
|
|
90
|
-
line=2,
|
|
91
98
|
keyword="",
|
|
92
99
|
title="",
|
|
93
100
|
description="",
|
|
94
101
|
steps=[
|
|
95
|
-
Step.new(7, "Given", "y is 5")
|
|
102
|
+
Step.new(language, Location.new('foo.feature', 7), "Given", "y is 5")
|
|
96
103
|
])
|
|
97
104
|
background.feature = @feature
|
|
98
105
|
|