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