aslakhellesoy-cucumber 0.1.16.4 → 0.1.16.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +75 -1
- data/Manifest.txt +58 -65
- data/examples/cs/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/Rakefile +3 -3
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -6
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/de/features/addition.feature +6 -6
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/en/features/addition.feature +6 -6
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +1 -1
- data/examples/i18n/et/features/liitmine.feature +7 -6
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +1 -1
- data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +1 -1
- data/examples/i18n/fi/features/yhteenlasku.feature +2 -2
- data/examples/i18n/fr/features/addition.feature +2 -2
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +1 -1
- data/examples/i18n/id/features/addition.feature +6 -6
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -1
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +2 -3
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/lt/features/addition.feature +7 -6
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +7 -7
- data/examples/i18n/no/features/summering.feature +1 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +1 -1
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/jbehave/README.textile +17 -0
- data/examples/jbehave/features/support/env.rb +7 -0
- data/examples/jbehave/features/trading.feature +24 -0
- data/examples/jbehave/pom.xml +48 -0
- data/examples/self_test/README.textile +4 -1
- data/examples/self_test/features/call_undefined_step_from_step_def.feature +7 -0
- data/examples/self_test/features/lots_of_undefined.feature +8 -0
- data/examples/self_test/features/outline_sample.feature +8 -5
- data/examples/self_test/features/sample.feature +5 -3
- data/examples/self_test/features/step_definitions/sample_steps.rb +15 -3
- data/features/cucumber_cli.feature +199 -97
- data/features/cucumber_cli_outlines.feature +46 -38
- data/features/report_called_undefined_steps.feature +31 -0
- data/features/step_definitions/cucumber_steps.rb +7 -3
- data/features/step_definitions/extra_steps.rb +1 -1
- data/features/support/env.rb +1 -1
- data/gem_tasks/features.rake +1 -1
- data/gem_tasks/flog.rake +1 -1
- data/lib/autotest/cucumber_mixin.rb +16 -23
- data/lib/cucumber/ast/comment.rb +26 -0
- data/lib/cucumber/ast/examples.rb +22 -0
- data/lib/cucumber/ast/feature.rb +60 -0
- data/lib/cucumber/ast/features.rb +39 -0
- data/lib/cucumber/ast/filter.rb +22 -0
- data/lib/cucumber/ast/outline_table.rb +49 -0
- data/lib/cucumber/ast/py_string.rb +52 -0
- data/lib/cucumber/ast/scenario.rb +91 -0
- data/lib/cucumber/ast/scenario_outline.rb +83 -0
- data/lib/cucumber/ast/step.rb +130 -0
- data/lib/cucumber/ast/table.rb +214 -0
- data/lib/cucumber/ast/tags.rb +33 -0
- data/lib/cucumber/ast/visitor.rb +93 -0
- data/lib/cucumber/ast.rb +27 -0
- data/lib/cucumber/broadcaster.rb +1 -6
- data/lib/cucumber/cli.rb +178 -128
- data/lib/cucumber/core_ext/exception.rb +41 -8
- data/lib/cucumber/core_ext/instance_exec.rb +54 -0
- data/lib/cucumber/core_ext/proc.rb +29 -65
- data/lib/cucumber/core_ext/string.rb +19 -0
- data/lib/cucumber/{formatters → formatter}/ansicolor.rb +11 -10
- data/lib/cucumber/formatter/console.rb +116 -0
- data/lib/cucumber/formatter/pretty.rb +158 -0
- data/lib/cucumber/formatter/profile.rb +77 -0
- data/lib/cucumber/formatter/progress.rb +68 -0
- data/lib/cucumber/formatter.rb +1 -0
- data/lib/cucumber/formatters/autotest_formatter.rb +0 -2
- data/lib/cucumber/formatters/html_formatter.rb +4 -3
- data/lib/cucumber/formatters/pretty_formatter.rb +1 -1
- data/lib/cucumber/formatters/unicode.rb +3 -3
- data/lib/cucumber/jbehave.rb +104 -0
- data/lib/cucumber/languages.yml +100 -73
- data/lib/cucumber/parser/basic.rb +0 -0
- data/lib/cucumber/parser/feature.rb +1694 -0
- data/lib/cucumber/parser/feature.tt +206 -0
- data/lib/cucumber/parser/file_parser.rb +50 -0
- data/lib/cucumber/parser/i18n.tt +26 -0
- data/lib/cucumber/parser/treetop_ext.rb +9 -0
- data/lib/cucumber/parser.rb +27 -0
- data/lib/cucumber/platform.rb +3 -17
- data/lib/cucumber/step_definition.rb +83 -0
- data/lib/cucumber/step_mother.rb +128 -72
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber.rb +56 -9
- data/spec/cucumber/ast/feature_factory.rb +54 -0
- data/spec/cucumber/ast/feature_spec.rb +60 -0
- data/spec/cucumber/ast/py_string_spec.rb +40 -0
- data/spec/cucumber/ast/scenario_outline_spec.rb +64 -0
- data/spec/cucumber/ast/scenario_spec.rb +82 -0
- data/spec/cucumber/ast/step_spec.rb +45 -0
- data/spec/cucumber/ast/table_spec.rb +81 -0
- data/spec/cucumber/broadcaster_spec.rb +4 -17
- data/spec/cucumber/cli_spec.rb +43 -148
- data/spec/cucumber/core_ext/proc_spec.rb +27 -35
- data/spec/cucumber/core_ext/string_spec.rb +8 -0
- data/spec/cucumber/{formatters → formatter}/ansicolor_spec.rb +2 -2
- data/spec/cucumber/formatter/html/cucumber.css +37 -0
- data/spec/cucumber/formatter/html/cucumber.js +11 -0
- data/spec/cucumber/formatter/html/index.html +45 -0
- data/spec/cucumber/formatter/html/jquery-1.3.min.js +19 -0
- data/spec/cucumber/formatter/html/jquery.uitableedit.js +100 -0
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +1 -0
- data/spec/cucumber/formatters/profile_formatter_spec.rb +17 -16
- data/spec/cucumber/parser/feature_parser_spec.rb +247 -0
- data/spec/cucumber/parser/table_parser_spec.rb +48 -0
- data/spec/cucumber/step_definition_spec.rb +62 -0
- data/spec/cucumber/step_mom_spec.rb +49 -0
- data/spec/cucumber/treetop_parser/empty_feature.feature +1 -1
- data/spec/cucumber/treetop_parser/spaces.feature +3 -1
- data/spec/cucumber/treetop_parser/with_comments.feature +1 -1
- data/spec/cucumber/treetop_parser/with_tags.feature +18 -0
- data/spec/cucumber/world/pending_spec.rb +13 -12
- data/spec/spec_helper.rb +1 -1
- metadata +59 -67
- data/examples/calculator_ruby_features/Rakefile +0 -6
- data/examples/calculator_ruby_features/features/addition.rb +0 -39
- data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +0 -43
- data/gem_tasks/treetop.rake +0 -41
- data/lib/cucumber/executor.rb +0 -205
- data/lib/cucumber/formatters/profile_formatter.rb +0 -92
- data/lib/cucumber/formatters/progress_formatter.rb +0 -61
- data/lib/cucumber/formatters.rb +0 -1
- data/lib/cucumber/model/table.rb +0 -32
- data/lib/cucumber/model.rb +0 -1
- data/lib/cucumber/step_methods.rb +0 -49
- data/lib/cucumber/tree/feature.rb +0 -105
- data/lib/cucumber/tree/features.rb +0 -21
- data/lib/cucumber/tree/given_scenario.rb +0 -13
- data/lib/cucumber/tree/scenario.rb +0 -240
- data/lib/cucumber/tree/step.rb +0 -173
- data/lib/cucumber/tree/table.rb +0 -26
- data/lib/cucumber/tree/top_down_visitor.rb +0 -23
- data/lib/cucumber/tree.rb +0 -16
- data/lib/cucumber/treetop_parser/feature.treetop.erb +0 -254
- data/lib/cucumber/treetop_parser/feature_ar.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_cy.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_da.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_de.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en-lol.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_es.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_et.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_fr.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_id.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_it.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ja.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ko.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_lt.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_nl.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_no.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_parser.rb +0 -36
- data/lib/cucumber/treetop_parser/feature_pl.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_pt.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ro.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ro2.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ru.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_se.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +0 -1951
- data/lib/cucumber/world/pending.rb +0 -22
- data/lib/cucumber/world.rb +0 -1
- data/setup.rb +0 -1585
- data/spec/cucumber/executor_spec.rb +0 -382
- data/spec/cucumber/formatters/html_formatter_spec.rb +0 -104
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +0 -410
- data/spec/cucumber/formatters/progress_formatter_spec.rb +0 -81
- data/spec/cucumber/model/table_spec.rb +0 -32
- data/spec/cucumber/step_mother_spec.rb +0 -74
- data/spec/cucumber/tree/feature_spec.rb +0 -122
- data/spec/cucumber/tree/row_scenario_outline_spec.rb +0 -73
- data/spec/cucumber/tree/row_scenario_spec.rb +0 -55
- data/spec/cucumber/tree/row_step_outline_spec.rb +0 -38
- data/spec/cucumber/tree/scenario_outline_spec.rb +0 -50
- data/spec/cucumber/tree/scenario_spec.rb +0 -134
- data/spec/cucumber/tree/step_outline_spec.rb +0 -17
- data/spec/cucumber/tree/step_spec.rb +0 -59
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +0 -120
data/lib/cucumber/cli.rb
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'cucumber'
|
3
3
|
require 'ostruct'
|
4
|
+
require 'cucumber/parser'
|
5
|
+
require 'cucumber/formatter'
|
4
6
|
|
5
7
|
module Cucumber
|
6
8
|
class YmlLoadError < StandardError; end
|
7
9
|
|
8
10
|
class CLI
|
9
11
|
class << self
|
10
|
-
|
12
|
+
def step_mother=(step_mother)
|
13
|
+
@step_mother = step_mother
|
14
|
+
@step_mother.extend(StepMother)
|
15
|
+
@step_mother.snippet_generator = StepDefinition
|
16
|
+
end
|
11
17
|
|
12
18
|
def execute(args)
|
13
|
-
parse(args).execute!(@step_mother
|
19
|
+
parse(args).execute!(@step_mother)
|
14
20
|
end
|
15
21
|
|
16
22
|
def parse(args)
|
@@ -26,17 +32,18 @@ module Cucumber
|
|
26
32
|
|
27
33
|
def initialize(out_stream = STDOUT, error_stream = STDERR)
|
28
34
|
@out_stream = out_stream
|
35
|
+
|
29
36
|
@error_stream = error_stream
|
30
37
|
@paths = []
|
31
38
|
@options = {
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:formats => {},
|
39
|
+
:strict => false,
|
40
|
+
:require => nil,
|
41
|
+
:lang => 'en',
|
42
|
+
:dry_run => false,
|
43
|
+
:formats => {},
|
38
44
|
:excludes => [],
|
39
|
-
:
|
45
|
+
:tags => [],
|
46
|
+
:scenario_names => []
|
40
47
|
}
|
41
48
|
@active_format = DEFAULT_FORMAT
|
42
49
|
end
|
@@ -52,143 +59,156 @@ module Cucumber
|
|
52
59
|
"cucumber examples/i18n/en/features",
|
53
60
|
"cucumber --language it examples/i18n/it/features/somma.feature:6:98:113", "", ""
|
54
61
|
].join("\n")
|
55
|
-
opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
|
56
|
-
"
|
57
|
-
"
|
62
|
+
opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
|
63
|
+
"Require files before executing the features. If this",
|
64
|
+
"option is not specified, all *.rb files that are",
|
65
|
+
"siblings or below the features will be loaded auto-",
|
66
|
+
"matically. Automatic loading is disabled when this",
|
67
|
+
"option is specified, and all loading becomes explicit.",
|
68
|
+
"Files under directories named \"support\" are always",
|
69
|
+
"loaded first.",
|
58
70
|
"This option can be specified multiple times.") do |v|
|
59
71
|
@options[:require] ||= []
|
60
72
|
@options[:require] << v
|
61
73
|
end
|
62
|
-
opts.on("-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
opts.on("-l LANG", "--language LANG",
|
75
|
+
"Specify language for features (Default: #{@options[:lang]})",
|
76
|
+
%{Run with "--language help" to see all languages},
|
77
|
+
%{Run with "--language LANG help" to list keywords for LANG}) do |v|
|
78
|
+
if v == 'help'
|
79
|
+
list_languages
|
80
|
+
elsif args==['help']
|
81
|
+
list_keywords('en', v)
|
82
|
+
else
|
83
|
+
@options[:lang] = v
|
84
|
+
end
|
72
85
|
end
|
73
|
-
opts.on("-f FORMAT", "--format FORMAT",
|
86
|
+
opts.on("-f FORMAT", "--format FORMAT",
|
87
|
+
"How to format features (Default: #{DEFAULT_FORMAT})",
|
74
88
|
"Available formats: #{FORMATS.join(", ")}",
|
75
|
-
"You can also provide your own formatter classes as long
|
76
|
-
"previously required using --require or
|
77
|
-
"structure such that cucumber
|
89
|
+
"You can also provide your own formatter classes as long",
|
90
|
+
"as they have been previously required using --require or",
|
91
|
+
"if they are in the folder structure such that cucumber",
|
92
|
+
"will require them automatically.",
|
78
93
|
"This option can be specified multiple times.") do |v|
|
79
|
-
|
80
|
-
@options[:formats][v] ||= []
|
81
|
-
@options[:formats][v] << @out_stream
|
94
|
+
@options[:formats][v] = @out_stream
|
82
95
|
@active_format = v
|
83
96
|
end
|
84
|
-
opts.on("-o", "--out FILE",
|
85
|
-
"
|
86
|
-
"specified --format
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
97
|
+
opts.on("-o", "--out FILE",
|
98
|
+
"Write output to a file instead of STDOUT. This option",
|
99
|
+
"applies to the previously specified --format, or the",
|
100
|
+
"default format if no format is specified.") do |v|
|
101
|
+
@options[:formats][@active_format] = v
|
102
|
+
end
|
103
|
+
opts.on("-t TAGS", "--tags TAGS",
|
104
|
+
"Only execute the features or scenarios with the specified tags.",
|
105
|
+
"TAGS must be comma-separated without spaces.") do |v|
|
106
|
+
@options[:tags] = v.split(",")
|
93
107
|
end
|
94
|
-
opts.on("-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
@options[:color] = v
|
108
|
+
opts.on("-s SCENARIO", "--scenario SCENARIO",
|
109
|
+
"Only execute the scenario with the given name. If this option",
|
110
|
+
"is given more than once, run all the specified scenarios.") do |v|
|
111
|
+
@options[:scenario_names] << v
|
99
112
|
end
|
100
|
-
opts.on("-e", "--exclude PATTERN", "Don't run
|
113
|
+
opts.on("-e", "--exclude PATTERN", "Don't run feature files matching PATTERN") do |v|
|
101
114
|
@options[:excludes] << v
|
102
115
|
end
|
103
116
|
opts.on("-p", "--profile PROFILE", "Pull commandline arguments from cucumber.yml.") do |v|
|
104
117
|
parse_args_from_profile(v)
|
105
118
|
end
|
106
|
-
opts.on("-
|
119
|
+
opts.on("-c", "--[no-]color",
|
120
|
+
"Whether or not to use ANSI color in the output. Cucumber decides",
|
121
|
+
"based on your platform and the output destination if not specified.") do |v|
|
122
|
+
Term::ANSIColor.coloring = v
|
123
|
+
end
|
124
|
+
opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.",
|
125
|
+
"Implies --quiet.") do
|
126
|
+
@options[:dry_run] = true
|
127
|
+
@quiet = true
|
128
|
+
end
|
129
|
+
opts.on("-a", "--autoformat DIRECTORY",
|
130
|
+
"Reformats (pretty prints) feature files and write them to DIRECTORY.",
|
131
|
+
"Be careful if you choose to overwrite the originals.",
|
132
|
+
"Implies --dry-run --formatter pretty.") do |directory|
|
133
|
+
@options[:autoformat] = directory
|
134
|
+
Term::ANSIColor.coloring = false
|
107
135
|
@options[:dry_run] = true
|
136
|
+
@quiet = true
|
108
137
|
end
|
109
|
-
opts.on("-n", "--no-source",
|
110
|
-
|
138
|
+
opts.on("-n", "--[no-]source",
|
139
|
+
"Don't show the file and line of the step definition with the steps.") do |v|
|
140
|
+
@options[:source] = v
|
111
141
|
end
|
112
|
-
opts.on("-i", "--no-snippets", "Don't show the snippets for pending steps") do
|
113
|
-
@options[:snippets] =
|
142
|
+
opts.on("-i", "--[no-]snippets", "Don't show the snippets for pending steps.") do |v|
|
143
|
+
@options[:snippets] = v
|
114
144
|
end
|
115
|
-
opts.on("-q", "--quiet", "
|
116
|
-
@
|
117
|
-
@options[:source] = false
|
145
|
+
opts.on("-q", "--quiet", "Alias for --no-snippets --no-source.") do
|
146
|
+
@quiet = true
|
118
147
|
end
|
119
|
-
opts.on("-b", "--backtrace", "Show full backtrace for all errors") do
|
148
|
+
opts.on("-b", "--backtrace", "Show full backtrace for all errors.") do
|
120
149
|
Exception.cucumber_full_backtrace = true
|
121
150
|
end
|
122
|
-
opts.on("
|
151
|
+
opts.on("--strict", "Fail if there are any undefined or pending steps.") do
|
152
|
+
@options[:strict] = true
|
153
|
+
end
|
154
|
+
opts.on("-v", "--verbose", "Show the files and features loaded.") do
|
123
155
|
@options[:verbose] = true
|
124
156
|
end
|
125
|
-
opts.on_tail("--version", "Show version") do
|
157
|
+
opts.on_tail("--version", "Show version.") do
|
126
158
|
@out_stream.puts VERSION::STRING
|
127
159
|
Kernel.exit
|
128
160
|
end
|
129
|
-
opts.on_tail("--help", "You're looking at it") do
|
161
|
+
opts.on_tail("--help", "You're looking at it.") do
|
130
162
|
@out_stream.puts opts.help
|
131
163
|
Kernel.exit
|
132
164
|
end
|
133
165
|
end.parse!
|
134
166
|
|
135
|
-
if @options[:formats].empty?
|
136
|
-
|
137
|
-
|
138
|
-
|
167
|
+
@options[:formats]['pretty'] = @out_stream if @options[:formats].empty?
|
168
|
+
|
169
|
+
@options[:snippets] = true if !@quiet && @options[:snippets].nil?
|
170
|
+
@options[:source] = true if !@quiet && @options[:source].nil?
|
171
|
+
|
139
172
|
# Whatever is left after option parsing is the FILE arguments
|
140
|
-
args = extract_and_store_line_numbers(args)
|
141
173
|
@paths += args
|
142
174
|
end
|
143
175
|
|
144
176
|
|
145
|
-
def execute!(step_mother
|
146
|
-
Term::ANSIColor.coloring = @options[:color] unless @options[:color].nil?
|
177
|
+
def execute!(step_mother)
|
147
178
|
Cucumber.load_language(@options[:lang])
|
148
179
|
require_files
|
149
180
|
enable_diffing
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
181
|
+
features = load_plain_text_features
|
182
|
+
|
183
|
+
visitor = build_formatter_broadcaster(step_mother)
|
184
|
+
visitor.options = @options
|
185
|
+
visitor.visit_features(features)
|
186
|
+
exit_code = features.steps[:failed].length
|
187
|
+
exit_code += (features.steps[:undefined].length + features.steps[:pending].length) if @options[:strict]
|
188
|
+
Kernel.exit(exit_code)
|
157
189
|
end
|
158
190
|
|
159
191
|
private
|
160
192
|
|
161
|
-
def extract_and_store_line_numbers(file_arguments)
|
162
|
-
@options[:lines_for_features] = Hash.new{|k,v| k[v] = []}
|
163
|
-
file_arguments.map do |arg|
|
164
|
-
_, file, lines = */^([\w\W]*?):([\d:]+)$/.match(arg)
|
165
|
-
unless file.nil?
|
166
|
-
@options[:lines_for_features][file] += lines.split(':').map { |line| line.to_i }
|
167
|
-
arg = file
|
168
|
-
end
|
169
|
-
arg
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
193
|
def cucumber_yml
|
174
194
|
return @cucumber_yml if @cucumber_yml
|
175
195
|
unless File.exist?('cucumber.yml')
|
176
196
|
raise(YmlLoadError,"cucumber.yml was not found. Please refer to cucumber's documentaion on defining profiles in cucumber.yml. You must define a 'default' profile to use the cucumber command without any arguments.\nType 'cucumber --help' for usage.\n")
|
177
197
|
end
|
178
|
-
|
198
|
+
|
179
199
|
require 'yaml'
|
180
200
|
begin
|
181
201
|
@cucumber_yml = YAML::load(IO.read('cucumber.yml'))
|
182
202
|
rescue Exception => e
|
183
203
|
raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentaion on correct profile usage.\n")
|
184
|
-
|
185
|
-
|
204
|
+
end
|
205
|
+
|
186
206
|
if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
|
187
207
|
raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentaion on correct profile usage.\n")
|
188
208
|
end
|
189
209
|
|
190
210
|
return @cucumber_yml
|
191
|
-
end
|
211
|
+
end
|
192
212
|
|
193
213
|
def parse_args_from_profile(profile)
|
194
214
|
unless cucumber_yml.has_key?(profile)
|
@@ -209,7 +229,7 @@ Defined profiles in cucumber.yml:
|
|
209
229
|
else
|
210
230
|
parse_options!(args_from_yml.split(' '))
|
211
231
|
end
|
212
|
-
|
232
|
+
|
213
233
|
rescue YmlLoadError => e
|
214
234
|
exit_with_error(e.message)
|
215
235
|
end
|
@@ -218,8 +238,6 @@ Defined profiles in cucumber.yml:
|
|
218
238
|
# Requires files - typically step files and ruby feature files.
|
219
239
|
def require_files
|
220
240
|
@args.clear # Shut up RSpec
|
221
|
-
require "cucumber/treetop_parser/feature_#{@options[:lang]}"
|
222
|
-
require "cucumber/treetop_parser/feature_parser"
|
223
241
|
|
224
242
|
verbose_log("Ruby files required:")
|
225
243
|
files_to_require.each do |lib|
|
@@ -233,7 +251,7 @@ Defined profiles in cucumber.yml:
|
|
233
251
|
end
|
234
252
|
verbose_log("\n")
|
235
253
|
end
|
236
|
-
|
254
|
+
|
237
255
|
def files_to_require
|
238
256
|
requires = @options[:require] || feature_dirs
|
239
257
|
files = requires.map do |path|
|
@@ -263,57 +281,52 @@ Defined profiles in cucumber.yml:
|
|
263
281
|
feature_files.map{|f| File.directory?(f) ? f : File.dirname(f)}.uniq
|
264
282
|
end
|
265
283
|
|
266
|
-
def load_plain_text_features
|
267
|
-
|
284
|
+
def load_plain_text_features
|
285
|
+
filter = Ast::Filter.new(@options)
|
286
|
+
features = Ast::Features.new(filter)
|
287
|
+
parser = Parser::FeatureParser.new
|
268
288
|
|
269
289
|
verbose_log("Features:")
|
270
290
|
feature_files.each do |f|
|
271
|
-
features
|
291
|
+
features.add_feature(parser.parse_file(f))
|
272
292
|
verbose_log(" * #{f}")
|
273
293
|
end
|
274
294
|
verbose_log("\n"*2)
|
295
|
+
features
|
275
296
|
end
|
276
297
|
|
277
298
|
def build_formatter_broadcaster(step_mother)
|
278
|
-
|
279
|
-
@options[:formats].
|
280
|
-
|
299
|
+
return Formatter::Pretty.new(step_mother, nil, @options) if @options[:autoformat]
|
300
|
+
formatters = @options[:formats].map do |format, out|
|
301
|
+
if String === out # file name
|
302
|
+
out = File.open(out, Cucumber.file_mode('w'))
|
303
|
+
at_exit do
|
304
|
+
out.flush
|
305
|
+
out.close
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
281
309
|
case format
|
282
310
|
when 'pretty'
|
283
|
-
|
311
|
+
Formatter::Pretty.new(step_mother, out, @options)
|
284
312
|
when 'progress'
|
285
|
-
|
313
|
+
Formatter::Progress.new(step_mother, out, @options)
|
286
314
|
when 'profile'
|
287
|
-
|
288
|
-
when '
|
289
|
-
|
290
|
-
when 'autotest'
|
291
|
-
formatter_broadcaster.register(Formatters::AutotestFormatter.new(output_broadcaster))
|
315
|
+
Formatter::Profile.new(step_mother, out, @options)
|
316
|
+
when 'rerun'
|
317
|
+
Formatter::Rerun.new(step_mother, out, @options)
|
292
318
|
else
|
293
319
|
begin
|
294
320
|
formatter_class = constantize(format)
|
295
|
-
|
296
|
-
rescue NameError => e
|
297
|
-
@error_stream.puts "Invalid format: #{format}\n"
|
298
|
-
exit_with_help
|
321
|
+
formatter_class.new(step_mother, out, @options)
|
299
322
|
rescue Exception => e
|
300
|
-
exit_with_error("Error creating formatter: #{format}
|
323
|
+
exit_with_error("Error creating formatter: #{format}", e)
|
301
324
|
end
|
302
325
|
end
|
303
326
|
end
|
304
|
-
|
327
|
+
Broadcaster.new(formatters)
|
305
328
|
end
|
306
329
|
|
307
|
-
def build_output_broadcaster(output_list)
|
308
|
-
output_broadcaster = Broadcaster.new
|
309
|
-
output_list.each do |output|
|
310
|
-
output_broadcaster.register(output)
|
311
|
-
end
|
312
|
-
output_broadcaster
|
313
|
-
end
|
314
|
-
|
315
|
-
private
|
316
|
-
|
317
330
|
def constantize(camel_cased_word)
|
318
331
|
names = camel_cased_word.split('::')
|
319
332
|
names.shift if names.empty? || names.first.empty?
|
@@ -324,7 +337,7 @@ Defined profiles in cucumber.yml:
|
|
324
337
|
end
|
325
338
|
constant
|
326
339
|
end
|
327
|
-
|
340
|
+
|
328
341
|
def verbose_log(string)
|
329
342
|
@out_stream.puts(string) if @options[:verbose]
|
330
343
|
end
|
@@ -333,8 +346,12 @@ Defined profiles in cucumber.yml:
|
|
333
346
|
parse_options!(%w{--help})
|
334
347
|
end
|
335
348
|
|
336
|
-
def exit_with_error(error_message)
|
337
|
-
@error_stream
|
349
|
+
def exit_with_error(error_message, e=nil)
|
350
|
+
@error_stream.puts(error_message)
|
351
|
+
if e
|
352
|
+
@error_stream.puts("#{e.message} (#{e.class})")
|
353
|
+
@error_stream.puts(e.backtrace.join("\n"))
|
354
|
+
end
|
338
355
|
Kernel.exit 1
|
339
356
|
end
|
340
357
|
|
@@ -345,12 +362,45 @@ Defined profiles in cucumber.yml:
|
|
345
362
|
::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
|
346
363
|
end
|
347
364
|
end
|
365
|
+
|
366
|
+
def list_languages
|
367
|
+
raw = Cucumber::LANGUAGES.keys.sort.map do |lang|
|
368
|
+
[lang, Cucumber::LANGUAGES[lang]['name'], Cucumber::LANGUAGES[lang]['native']]
|
369
|
+
end
|
370
|
+
print_table(raw)
|
371
|
+
end
|
372
|
+
|
373
|
+
def list_keywords(ref, lang)
|
374
|
+
unless Cucumber::LANGUAGES[lang]
|
375
|
+
exit_with_error("No language with key #{v}")
|
376
|
+
end
|
377
|
+
Cucumber.load_language(lang)
|
378
|
+
raw = %w{feature background scenario scenario_outline examples given when then but}.map do |key|
|
379
|
+
[Cucumber::LANGUAGES[ref][key], Cucumber::LANGUAGES[lang][key]]
|
380
|
+
end
|
381
|
+
print_table(raw)
|
382
|
+
end
|
383
|
+
|
384
|
+
def print_table(raw)
|
385
|
+
table = Ast::Table.new(raw)
|
386
|
+
formatter = Formatter::Pretty.new(nil, @out_stream, {}, '')
|
387
|
+
|
388
|
+
def formatter.visit_table_row(table_row, status)
|
389
|
+
@col = 1
|
390
|
+
super
|
391
|
+
end
|
392
|
+
|
393
|
+
def formatter.visit_table_cell_value(value, width, status)
|
394
|
+
status = :comment if @col == 1
|
395
|
+
@col += 1
|
396
|
+
super(value, width, status)
|
397
|
+
end
|
398
|
+
|
399
|
+
formatter.indent = 0
|
400
|
+
formatter.visit_multiline_arg(table, :passed)
|
401
|
+
Kernel.exit
|
402
|
+
end
|
348
403
|
end
|
349
404
|
end
|
350
405
|
|
351
|
-
|
352
|
-
Cucumber::CLI.step_mother = step_mother
|
353
|
-
Cucumber::CLI.executor = executor
|
354
|
-
|
355
|
-
extend Cucumber::Tree
|
356
|
-
Cucumber::CLI.features = features
|
406
|
+
Cucumber::CLI.step_mother = self
|
@@ -1,20 +1,53 @@
|
|
1
|
+
# Exception extension that tweaks Exception backtraces:
|
2
|
+
#
|
3
|
+
# * The line of the failing .feature line is appended to the backtrace
|
4
|
+
# * The line that calls #cucumber_instance_exec is replaced with the StepDefinition's regexp
|
5
|
+
# * Non intersting lines are stripped out
|
6
|
+
#
|
7
|
+
# The result is that backtraces look like this:
|
8
|
+
#
|
9
|
+
# features/step_definitions/the_step_definition.rb:in `/some step/'
|
10
|
+
# features/the_feature_file.feature:41:in `Given some step'
|
11
|
+
#
|
12
|
+
# or if the exception is raised in the tested code:
|
13
|
+
#
|
14
|
+
# lib/myapp/some_file.rb:in `/some_method/'
|
15
|
+
# lib/myapp/some_other_file.rb:in `/some_other_method/'
|
16
|
+
# features/step_definitions/the_step_definition.rb:in `/some step/'
|
17
|
+
# features/the_feature_file.feature:41:in `Given some step'
|
18
|
+
#
|
19
|
+
# All backtrace munging can be turned off with the <tt>--backtrace</tt> switch
|
20
|
+
#
|
1
21
|
class Exception
|
2
22
|
CUCUMBER_FILTER_PATTERNS = [
|
3
|
-
/vendor\/rails
|
4
|
-
/vendor\/plugins\/cucumber/,
|
5
|
-
/vendor\/plugins\/rspec/,
|
6
|
-
/gems\/rspec/
|
23
|
+
/vendor\/rails|lib\/cucumber|lib\/rspec|gems\//
|
7
24
|
]
|
8
25
|
|
26
|
+
INSTANCE_EXEC_OFFSET = (Cucumber::RUBY_1_9 || Cucumber::JRUBY) ? -3 : -4
|
27
|
+
|
9
28
|
def self.cucumber_full_backtrace=(v)
|
10
29
|
@@cucumber_full_backtrace = v
|
11
30
|
end
|
12
31
|
self.cucumber_full_backtrace = false
|
13
32
|
|
14
|
-
|
15
|
-
|
16
|
-
|
33
|
+
# Strips the backtrace from +line+ and down
|
34
|
+
def self.cucumber_strip_backtrace!(backtrace, instance_exec_invocation_line, pseudo_method)
|
35
|
+
return if @@cucumber_full_backtrace
|
36
|
+
|
37
|
+
instance_exec_pos = backtrace.index(instance_exec_invocation_line)
|
38
|
+
if instance_exec_pos
|
39
|
+
replacement_line = instance_exec_pos + INSTANCE_EXEC_OFFSET
|
40
|
+
backtrace[replacement_line].gsub!(/`.*'/, "`#{pseudo_method}'") if pseudo_method
|
41
|
+
backtrace[replacement_line+1..-1] = nil
|
42
|
+
|
43
|
+
backtrace.compact!
|
44
|
+
else
|
45
|
+
# This happens with rails, because they screw up the backtrace
|
46
|
+
# before we get here (injecting erb stacktrace and such)
|
47
|
+
end
|
48
|
+
|
49
|
+
backtrace.reject! do |line|
|
17
50
|
CUCUMBER_FILTER_PATTERNS.detect{|p| line =~ p}
|
18
|
-
end
|
51
|
+
end
|
19
52
|
end
|
20
53
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'cucumber/platform'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
class ArityMismatchError < StandardError
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class Object
|
9
|
+
def cucumber_instance_exec(check_arity, pseudo_method, *args, &block)
|
10
|
+
arity = block.arity
|
11
|
+
arity = 0 if arity == -1
|
12
|
+
cucumber_run_with_backtrace_filtering(pseudo_method) do
|
13
|
+
if check_arity && args.length != arity
|
14
|
+
instance_exec do
|
15
|
+
raise Cucumber::ArityMismatchError.new("expected #{arity} block argument(s), got #{args.length}")
|
16
|
+
end
|
17
|
+
else
|
18
|
+
instance_exec(*args, &block)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def cucumber_run_with_backtrace_filtering(pseudo_method)
|
24
|
+
begin
|
25
|
+
yield
|
26
|
+
rescue Exception => e
|
27
|
+
instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
|
28
|
+
Exception.cucumber_strip_backtrace!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
|
29
|
+
raise e
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
unless defined? instance_exec # 1.9
|
34
|
+
# http://eigenclass.org/hiki/bounded+space+instance_exec
|
35
|
+
module InstanceExecHelper; end
|
36
|
+
include InstanceExecHelper
|
37
|
+
def instance_exec(*args, &block)
|
38
|
+
begin
|
39
|
+
old_critical, Thread.critical = Thread.critical, true
|
40
|
+
n = 0
|
41
|
+
n += 1 while respond_to?(mname="__instance_exec#{n}")
|
42
|
+
InstanceExecHelper.module_eval{ define_method(mname, &block) }
|
43
|
+
ensure
|
44
|
+
Thread.critical = old_critical
|
45
|
+
end
|
46
|
+
begin
|
47
|
+
ret = send(mname, *args)
|
48
|
+
ensure
|
49
|
+
InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
|
50
|
+
end
|
51
|
+
ret
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|