lucid 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +30 -10
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +15 -0
- data/Gemfile +4 -2
- data/HISTORY.md +22 -0
- data/{LICENSE.txt → LICENSE} +6 -3
- data/README.md +22 -8
- data/Rakefile +2 -1
- data/bin/lucid +10 -10
- data/bin/lucid-gen +4 -0
- data/lib/autotest/discover.rb +11 -0
- data/lib/autotest/lucid.rb +6 -0
- data/lib/autotest/lucid_mixin.rb +135 -0
- data/lib/autotest/lucid_rails.rb +6 -0
- data/lib/autotest/lucid_rails_rspec.rb +6 -0
- data/lib/autotest/lucid_rails_rspec2.rb +6 -0
- data/lib/autotest/lucid_rspec.rb +6 -0
- data/lib/autotest/lucid_rspec2.rb +6 -0
- data/lib/lucid.rb +32 -1
- data/lib/lucid/ast.rb +20 -0
- data/lib/lucid/ast/background.rb +116 -0
- data/lib/lucid/ast/comment.rb +24 -0
- data/lib/lucid/ast/doc_string.rb +44 -0
- data/lib/lucid/ast/empty_background.rb +33 -0
- data/lib/lucid/ast/examples.rb +49 -0
- data/lib/lucid/ast/feature.rb +99 -0
- data/lib/lucid/ast/has_steps.rb +74 -0
- data/lib/lucid/ast/location.rb +41 -0
- data/lib/lucid/ast/multiline_argument.rb +31 -0
- data/lib/lucid/ast/names.rb +13 -0
- data/lib/lucid/ast/outline_table.rb +194 -0
- data/lib/lucid/ast/scenario.rb +103 -0
- data/lib/lucid/ast/scenario_outline.rb +144 -0
- data/lib/lucid/ast/specs.rb +38 -0
- data/lib/lucid/ast/step.rb +122 -0
- data/lib/lucid/ast/step_collection.rb +92 -0
- data/lib/lucid/ast/step_invocation.rb +196 -0
- data/lib/lucid/ast/table.rb +730 -0
- data/lib/lucid/ast/tags.rb +28 -0
- data/lib/lucid/ast/tdl_walker.rb +195 -0
- data/lib/lucid/cli/app.rb +78 -0
- data/lib/lucid/cli/configuration.rb +261 -0
- data/lib/lucid/cli/options.rb +463 -0
- data/lib/lucid/cli/profile.rb +101 -0
- data/lib/lucid/configuration.rb +53 -0
- data/lib/lucid/core_ext/disable_autorunners.rb +15 -0
- data/lib/lucid/core_ext/instance_exec.rb +70 -0
- data/lib/lucid/core_ext/proc.rb +36 -0
- data/lib/lucid/core_ext/string.rb +9 -0
- data/lib/lucid/errors.rb +40 -0
- data/lib/lucid/factory.rb +43 -0
- data/lib/lucid/formatter/ansicolor.rb +168 -0
- data/lib/lucid/formatter/console.rb +218 -0
- data/lib/lucid/formatter/debug.rb +33 -0
- data/lib/lucid/formatter/duration.rb +11 -0
- data/lib/lucid/formatter/gherkin_formatter_adapter.rb +94 -0
- data/lib/lucid/formatter/gpretty.rb +24 -0
- data/lib/lucid/formatter/html.rb +610 -0
- data/lib/lucid/formatter/interceptor.rb +66 -0
- data/lib/lucid/formatter/io.rb +31 -0
- data/lib/lucid/formatter/jquery-min.js +154 -0
- data/lib/lucid/formatter/json.rb +19 -0
- data/lib/lucid/formatter/json_pretty.rb +10 -0
- data/lib/lucid/formatter/junit.rb +177 -0
- data/lib/lucid/formatter/lucid.css +283 -0
- data/lib/lucid/formatter/lucid.sass +244 -0
- data/lib/lucid/formatter/ordered_xml_markup.rb +24 -0
- data/lib/lucid/formatter/progress.rb +95 -0
- data/lib/lucid/formatter/rerun.rb +91 -0
- data/lib/lucid/formatter/standard.rb +235 -0
- data/lib/lucid/formatter/stepdefs.rb +14 -0
- data/lib/lucid/formatter/steps.rb +49 -0
- data/lib/lucid/formatter/summary.rb +35 -0
- data/lib/lucid/formatter/unicode.rb +53 -0
- data/lib/lucid/formatter/usage.rb +132 -0
- data/lib/lucid/generator.rb +21 -0
- data/lib/lucid/generators/project.rb +70 -0
- data/lib/lucid/generators/project/Gemfile.tt +6 -0
- data/lib/lucid/generators/project/browser-symbiont.rb +24 -0
- data/lib/lucid/generators/project/driver-symbiont.rb +4 -0
- data/lib/lucid/generators/project/errors.rb +26 -0
- data/lib/lucid/generators/project/events-symbiont.rb +36 -0
- data/lib/lucid/generators/project/lucid-symbiont.yml +6 -0
- data/lib/lucid/interface.rb +8 -0
- data/lib/lucid/interface_methods.rb +125 -0
- data/lib/lucid/interface_rb/matcher.rb +108 -0
- data/lib/lucid/interface_rb/rb_hook.rb +18 -0
- data/lib/lucid/interface_rb/rb_language.rb +190 -0
- data/lib/lucid/interface_rb/rb_lucid.rb +119 -0
- data/lib/lucid/interface_rb/rb_step_definition.rb +122 -0
- data/lib/lucid/interface_rb/rb_transform.rb +57 -0
- data/lib/lucid/interface_rb/rb_world.rb +136 -0
- data/lib/lucid/interface_rb/regexp_argument_matcher.rb +21 -0
- data/lib/lucid/load_path.rb +13 -0
- data/lib/lucid/parser.rb +2 -126
- data/lib/lucid/platform.rb +27 -0
- data/lib/lucid/rspec/allow_doubles.rb +20 -0
- data/lib/lucid/rspec/disallow_options.rb +27 -0
- data/lib/lucid/runtime.rb +200 -0
- data/lib/lucid/runtime/facade.rb +60 -0
- data/lib/lucid/runtime/interface_io.rb +60 -0
- data/lib/lucid/runtime/orchestrator.rb +218 -0
- data/lib/lucid/runtime/results.rb +64 -0
- data/lib/lucid/runtime/specs_loader.rb +79 -0
- data/lib/lucid/spec_file.rb +112 -0
- data/lib/lucid/step_definition_light.rb +20 -0
- data/lib/lucid/step_definitions.rb +13 -0
- data/lib/lucid/step_match.rb +99 -0
- data/lib/lucid/tdl_builder.rb +282 -0
- data/lib/lucid/term/ansicolor.rb +118 -0
- data/lib/lucid/unit.rb +11 -0
- data/lib/lucid/wire_support/configuration.rb +38 -0
- data/lib/lucid/wire_support/connection.rb +61 -0
- data/lib/lucid/wire_support/request_handler.rb +32 -0
- data/lib/lucid/wire_support/wire_exception.rb +32 -0
- data/lib/lucid/wire_support/wire_language.rb +54 -0
- data/lib/lucid/wire_support/wire_packet.rb +34 -0
- data/lib/lucid/wire_support/wire_protocol.rb +43 -0
- data/lib/lucid/wire_support/wire_protocol/requests.rb +125 -0
- data/lib/lucid/wire_support/wire_step_definition.rb +26 -0
- data/lucid.gemspec +25 -14
- metadata +220 -12
- data/lib/lucid/app.rb +0 -103
- data/lib/lucid/options.rb +0 -168
- data/lib/lucid/version.rb +0 -3
- data/lucid.yml +0 -8
@@ -0,0 +1,463 @@
|
|
1
|
+
require 'lucid/cli/profile'
|
2
|
+
require 'lucid/formatter/ansicolor'
|
3
|
+
require 'lucid/interface_rb/rb_language'
|
4
|
+
|
5
|
+
module Lucid
|
6
|
+
module CLI
|
7
|
+
class Options
|
8
|
+
|
9
|
+
INDENT = ' ' * 53
|
10
|
+
LUCID_FORMATS = {
|
11
|
+
'html' => ['Lucid::Formatter::Html', 'Generates an HTML report.'],
|
12
|
+
'standard' => ['Lucid::Formatter::Standard', 'Prints the spec as-is, using color if available.'],
|
13
|
+
'progress' => ['Lucid::Formatter::Progress', 'Prints one character per scenario.'],
|
14
|
+
'rerun' => ['Lucid::Formatter::Rerun', 'Prints failing specs with line numbers.'],
|
15
|
+
'usage' => ['Lucid::Formatter::Usage', "Prints where test definitions are used.\n" +
|
16
|
+
"#{INDENT}The slowest test definitions (with duration) are\n" +
|
17
|
+
"#{INDENT}listed first. If --dry-run is used the duration\n" +
|
18
|
+
"#{INDENT}is not shown, and test definitions are sorted by\n" +
|
19
|
+
"#{INDENT}file name instead."],
|
20
|
+
'stepdefs' => ['Lucid::Formatter::Stepdefs', "Prints all test definitions with their locations. Same as\n" +
|
21
|
+
"#{INDENT}the usage formatter, except that steps are not printed."],
|
22
|
+
'junit' => ['Lucid::Formatter::Junit', 'Generates a report similar to Ant+JUnit.'],
|
23
|
+
'json' => ['Lucid::Formatter::Json', 'Prints the spec as JSON.'],
|
24
|
+
'json_pretty' => ['Lucid::Formatter::JsonPretty', 'Prints the spec as prettified JSON.'],
|
25
|
+
'debug' => ['Lucid::Formatter::Debug', 'Prints the calls made to the listeners.']
|
26
|
+
}
|
27
|
+
largest = LUCID_FORMATS.keys.map{|s| s.length}.max
|
28
|
+
FORMAT_LIST = (LUCID_FORMATS.keys.sort.map do |key|
|
29
|
+
" #{key}#{' ' * (largest - key.length)} : #{LUCID_FORMATS[key][1]}"
|
30
|
+
end) + ["Use --format rerun --out specs.txt to write out failing",
|
31
|
+
"specs. You can rerun them with lucid @rerun.txt.",
|
32
|
+
"FORMAT can also be the fully qualified class name of",
|
33
|
+
"your own custom formatter. If the class isn't loaded,",
|
34
|
+
"Lucid will attempt to require a file with a relative",
|
35
|
+
"file name that is the underscore name of the class name.",
|
36
|
+
" Example: --format Formatter::WordDoc",
|
37
|
+
"With that, Lucid will look for formatter/word_doc.rb",
|
38
|
+
"You can place the file with this relative path",
|
39
|
+
"underneath your common/support directory or anywhere",
|
40
|
+
"on Ruby's LOAD_PATH."
|
41
|
+
]
|
42
|
+
PROFILE_SHORT_FLAG = '-p'
|
43
|
+
NO_PROFILE_SHORT_FLAG = '-P'
|
44
|
+
PROFILE_LONG_FLAG = '--profile'
|
45
|
+
NO_PROFILE_LONG_FLAG = '--no-profile'
|
46
|
+
OPTIONS_WITH_ARGS = ['-r', '--require', '--i18n', '-f', '--format', '-o', '--out',
|
47
|
+
'-t', '--tags', '-n', '--name', '-e', '--exclude',
|
48
|
+
PROFILE_SHORT_FLAG, PROFILE_LONG_FLAG,
|
49
|
+
'-a', '--autoformat', '-l', '--lines', '--port',
|
50
|
+
'-I', '--matcher-type']
|
51
|
+
|
52
|
+
def self.parse(args, out_stream, error_stream, options = {})
|
53
|
+
new(out_stream, error_stream, options).parse(args)
|
54
|
+
end
|
55
|
+
|
56
|
+
def initialize(out_stream = STDOUT, error_stream = STDERR, options = {})
|
57
|
+
@out_stream = out_stream
|
58
|
+
@error_stream = error_stream
|
59
|
+
|
60
|
+
@default_profile = options[:default_profile]
|
61
|
+
@profiles = []
|
62
|
+
@overridden_paths = []
|
63
|
+
@options = default_options
|
64
|
+
@profile_loader = options[:profile_loader]
|
65
|
+
@options[:skip_profile_information] = options[:skip_profile_information]
|
66
|
+
|
67
|
+
@quiet = @disable_profile_loading = nil
|
68
|
+
end
|
69
|
+
|
70
|
+
def [](key)
|
71
|
+
@options[key]
|
72
|
+
end
|
73
|
+
|
74
|
+
def []=(key, value)
|
75
|
+
@options[key] = value
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse(args)
|
79
|
+
@args = args
|
80
|
+
@expanded_args = @args.dup
|
81
|
+
|
82
|
+
@args.extend(::OptionParser::Arguable)
|
83
|
+
|
84
|
+
@args.options do |opts|
|
85
|
+
opts.banner = ["Lucid: Test Description Language Execution Engine",
|
86
|
+
"Usage: lucid [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+", "", ""
|
87
|
+
].join("\n")
|
88
|
+
|
89
|
+
opts.on("--library-path PATH", "Location of spec project library files.") do |path|
|
90
|
+
@options[:library_path] = path
|
91
|
+
end
|
92
|
+
|
93
|
+
opts.on("--spec-type TYPE", "The file type (extension) for Lucid specifications.") do |type|
|
94
|
+
@options[:spec_type] = type
|
95
|
+
end
|
96
|
+
|
97
|
+
opts.separator ""
|
98
|
+
|
99
|
+
opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
|
100
|
+
"Require files before executing the features. If this option",
|
101
|
+
"is not specified, all *.rb files that are siblings or below",
|
102
|
+
"the features will be loaded automatically. Automatic loading",
|
103
|
+
"is disabled when this option is specified. That means all",
|
104
|
+
"loading becomes explicit.",
|
105
|
+
"Files under directories named \"support\" will always be",
|
106
|
+
"loaded first.",
|
107
|
+
"This option can be specified multiple times.") do |v|
|
108
|
+
@options[:require] << v
|
109
|
+
if(Lucid::JRUBY && File.directory?(v))
|
110
|
+
require 'java'
|
111
|
+
$CLASSPATH << v
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
opts.separator ""
|
116
|
+
|
117
|
+
opts.on("-f FORMAT", "--format FORMAT",
|
118
|
+
"How Lucid will format spec execution output.",
|
119
|
+
"(Default: standard). Available formats:",
|
120
|
+
*FORMAT_LIST
|
121
|
+
) do |v|
|
122
|
+
@options[:formats] << [v, @out_stream]
|
123
|
+
end
|
124
|
+
|
125
|
+
opts.on("-o", "--out [FILE|DIR]",
|
126
|
+
"Write output to a file or directory instead of to standard",
|
127
|
+
"console output. This option applies to any specified format",
|
128
|
+
"option (via the --format switch) or to the default format",
|
129
|
+
"if no format was specified. You can check the specific",
|
130
|
+
"documentation for a given formatter to see whether to pass",
|
131
|
+
"a file or a directory."
|
132
|
+
) do |v|
|
133
|
+
@options[:formats] << ['standard', nil] if @options[:formats].empty?
|
134
|
+
@options[:formats][-1][1] = v
|
135
|
+
end
|
136
|
+
|
137
|
+
opts.separator ""
|
138
|
+
|
139
|
+
opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.",
|
140
|
+
"This also omits the loading of your support/env.rb file if it exists.") do
|
141
|
+
@options[:dry_run] = true
|
142
|
+
end
|
143
|
+
|
144
|
+
opts.on("-n NAME", "--name NAME",
|
145
|
+
"Lucid will only execute features or abilities that match with the name",
|
146
|
+
"provided. The match can be done on partial information. If this option",
|
147
|
+
"is provided multiple times, then the match will be performed against",
|
148
|
+
"each set of provided names."
|
149
|
+
) do |v|
|
150
|
+
@options[:name_regexps] << /#{v}/
|
151
|
+
end
|
152
|
+
|
153
|
+
opts.on("-l", "--lines LINES", "Run given line numbers. Equivalent to FILE:LINE syntax") do |lines|
|
154
|
+
@options[:lines] = lines
|
155
|
+
end
|
156
|
+
|
157
|
+
opts.on("-e", "--exclude PATTERN",
|
158
|
+
"Lucid will not use files that match the PATTERN.") do |v|
|
159
|
+
@options[:excludes] << Regexp.new(v)
|
160
|
+
end
|
161
|
+
|
162
|
+
opts.on("-t TAG_EXPRESSION", "--tags TAG_EXPRESSION",
|
163
|
+
"Lucid will only execute features or scenarios with tags that match the",
|
164
|
+
"tag expression provided. A single tag expressions can have several tags",
|
165
|
+
"separated by a comma, which represents a logical OR. If this option is",
|
166
|
+
"provided more than once, this represents a logical AND. A tag expression",
|
167
|
+
"can be prefaced with a ~ character, which represents a logical NOT.",
|
168
|
+
"Examples:",
|
169
|
+
" --tags @smoke.",
|
170
|
+
" --tags ~@wip",
|
171
|
+
" --tags @smoke,@wip",
|
172
|
+
" --tags @smoke,~@wip --tags @regression",
|
173
|
+
"If you want to use multiple exclusion tags, you must use the logical",
|
174
|
+
"AND approach, as in: --tags ~@wip --tags ~@failing",
|
175
|
+
"Positive tags can be given a threshold to limit the number of occurrences.",
|
176
|
+
"Example: --tags @critical:3",
|
177
|
+
"That will fail if there are more than three occurrences of the @critical tag."
|
178
|
+
) do |v|
|
179
|
+
@options[:tag_expressions] << v
|
180
|
+
end
|
181
|
+
|
182
|
+
opts.separator ""
|
183
|
+
|
184
|
+
opts.on(PROFILE_SHORT_FLAG, "#{PROFILE_LONG_FLAG} PROFILE",
|
185
|
+
"Pull commandline arguments from lucid.yml which can be defined as",
|
186
|
+
"strings or arrays. When a 'default' profile is defined and no profile",
|
187
|
+
"is specified it is always used. (Unless disabled, see -P below.)",
|
188
|
+
"When feature files are defined in a profile and on the command line",
|
189
|
+
"then only the ones from the command line are used."
|
190
|
+
) do |v|
|
191
|
+
@profiles << v
|
192
|
+
end
|
193
|
+
|
194
|
+
opts.on(NO_PROFILE_SHORT_FLAG, NO_PROFILE_LONG_FLAG,
|
195
|
+
"Disables all profile loading to avoid using the 'default' profile.") do |v|
|
196
|
+
@disable_profile_loading = true
|
197
|
+
end
|
198
|
+
|
199
|
+
opts.separator ""
|
200
|
+
|
201
|
+
opts.on("-c", "--[no-]color",
|
202
|
+
"Specifies whether or not to use ANSI color in the output. If this",
|
203
|
+
"option is not specified, Lucid makes the decision on colored output",
|
204
|
+
"based on your platform and the output destination."
|
205
|
+
) do |v|
|
206
|
+
Lucid::Term::ANSIColor.coloring = v
|
207
|
+
end
|
208
|
+
|
209
|
+
opts.on("-a", "--autoformat DIR",
|
210
|
+
"Reformats (pretty prints) spec files and write them to DIRECTORY.",
|
211
|
+
"Be careful if you choose to overwrite the originals.",
|
212
|
+
"Implies --dry-run --format pretty.") do |directory|
|
213
|
+
@options[:autoformat] = directory
|
214
|
+
Lucid::Term::ANSIColor.coloring = false
|
215
|
+
@options[:dry_run] = true
|
216
|
+
@quiet = true
|
217
|
+
end
|
218
|
+
|
219
|
+
opts.on("-m", "--no-multiline",
|
220
|
+
"Lucid will not print multiline strings and tables under steps.") do
|
221
|
+
@options[:no_multiline] = true
|
222
|
+
end
|
223
|
+
|
224
|
+
opts.on("-s", "--no-source",
|
225
|
+
"Lucid will not print the file and line of the test definition with the steps.") do
|
226
|
+
@options[:source] = false
|
227
|
+
end
|
228
|
+
|
229
|
+
opts.on("-i", "--no-matchers",
|
230
|
+
"Lucid will not print matchers for pending steps.") do
|
231
|
+
@options[:matchers] = false
|
232
|
+
end
|
233
|
+
|
234
|
+
opts.on("-I", "--matchers-type TYPE",
|
235
|
+
"Use different matcher type (Default: regexp).",
|
236
|
+
"Available types:",
|
237
|
+
*Lucid::InterfaceRb::RbLanguage.cli_matcher_type_options
|
238
|
+
) do |v|
|
239
|
+
@options[:matcher_type] = v.to_sym
|
240
|
+
end
|
241
|
+
|
242
|
+
opts.on("-q", "--quiet", "Alias for --no-matchers --no-source.") do
|
243
|
+
@quiet = true
|
244
|
+
end
|
245
|
+
|
246
|
+
opts.on("-S", "--strict", "Fail if there are any undefined or pending steps.") do
|
247
|
+
@options[:strict] = true
|
248
|
+
end
|
249
|
+
|
250
|
+
opts.on("-w", "--wip", "Fail if there are any passing scenarios.") do
|
251
|
+
@options[:wip] = true
|
252
|
+
end
|
253
|
+
|
254
|
+
opts.on("-g", "--guess", "Guess best match for ambiguous steps.") do
|
255
|
+
@options[:guess] = true
|
256
|
+
end
|
257
|
+
|
258
|
+
opts.on("-x", "--expand", "Expand Scenario Outline tables in output.") do
|
259
|
+
@options[:expand] = true
|
260
|
+
end
|
261
|
+
|
262
|
+
opts.separator ""
|
263
|
+
|
264
|
+
opts.on("--testdefs DIR", "Lucid will Write test definition metadata to the DIR.") do |dir|
|
265
|
+
@options[:testdefs] = dir
|
266
|
+
end
|
267
|
+
|
268
|
+
if(Lucid::JRUBY)
|
269
|
+
opts.on("-j DIR", "--jars DIR",
|
270
|
+
"Load all the jars under the specified directory.") do |jars|
|
271
|
+
Dir["#{jars}/**/*.jar"].each {|jar| require jar}
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
opts.on("--i18n LANG",
|
276
|
+
"List keywords for a particular language.",
|
277
|
+
%{Run with "--i18n help" to see all languages}) do |lang|
|
278
|
+
if lang == 'help'
|
279
|
+
list_languages_and_exit
|
280
|
+
else
|
281
|
+
list_keywords_and_exit(lang)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
opts.separator ""
|
286
|
+
|
287
|
+
opts.on("-b", "--backtrace", "Show full backtrace for all errors during Lucid execution.") do
|
288
|
+
Lucid.use_full_backtrace = true
|
289
|
+
end
|
290
|
+
|
291
|
+
opts.on("-v", "--verbose", "Show detailed information about Lucid execution.") do
|
292
|
+
@options[:verbose] = true
|
293
|
+
end
|
294
|
+
|
295
|
+
opts.on("--debug", "Show behind-the-scenes information about Lucid execution.") do
|
296
|
+
@options[:debug] = true
|
297
|
+
end
|
298
|
+
|
299
|
+
opts.separator ""
|
300
|
+
|
301
|
+
opts.on_tail("--version", "Show Lucid version information.") do
|
302
|
+
@out_stream.puts Lucid::VERSION
|
303
|
+
Kernel.exit(0)
|
304
|
+
end
|
305
|
+
|
306
|
+
opts.on_tail("-h", "--help", "Show Lucid execution options.") do
|
307
|
+
@out_stream.puts opts.help
|
308
|
+
Kernel.exit(0)
|
309
|
+
end
|
310
|
+
end.parse!
|
311
|
+
|
312
|
+
if @quiet
|
313
|
+
@options[:matchers] = @options[:source] = false
|
314
|
+
else
|
315
|
+
@options[:matchers] = true if @options[:matchers].nil?
|
316
|
+
@options[:source] = true if @options[:source].nil?
|
317
|
+
end
|
318
|
+
@args.map! { |a| "#{a}:#{@options[:lines]}" } if @options[:lines]
|
319
|
+
|
320
|
+
extract_environment_variables
|
321
|
+
|
322
|
+
# This line grabs whatever is left over on the command line. That
|
323
|
+
# would have to be the spec repo.
|
324
|
+
@options[:spec_source] = @args.dup
|
325
|
+
|
326
|
+
establish_profile
|
327
|
+
|
328
|
+
self
|
329
|
+
end
|
330
|
+
|
331
|
+
def custom_profiles
|
332
|
+
@profiles - [@default_profile]
|
333
|
+
end
|
334
|
+
|
335
|
+
# @see Lucid::CLI::Configuration.filters
|
336
|
+
def filters
|
337
|
+
@options.values_at(:name_regexps, :tag_expressions).select{|v| !v.empty?}.first || []
|
338
|
+
end
|
339
|
+
|
340
|
+
protected
|
341
|
+
|
342
|
+
attr_reader :options, :profiles, :expanded_args
|
343
|
+
protected :options, :profiles, :expanded_args
|
344
|
+
|
345
|
+
private
|
346
|
+
|
347
|
+
def non_stdout_formats
|
348
|
+
@options[:formats].select {|format, output| output != @out_stream }
|
349
|
+
end
|
350
|
+
|
351
|
+
def stdout_formats
|
352
|
+
@options[:formats].select {|format, output| output == @out_stream }
|
353
|
+
end
|
354
|
+
|
355
|
+
def extract_environment_variables
|
356
|
+
@args.delete_if do |arg|
|
357
|
+
if arg =~ /^(\w+)=(.*)$/
|
358
|
+
@options[:env_vars][$1] = $2
|
359
|
+
true
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
def disable_profile_loading?
|
365
|
+
@disable_profile_loading
|
366
|
+
end
|
367
|
+
|
368
|
+
def establish_profile
|
369
|
+
if @disable_profile_loading
|
370
|
+
@out_stream.puts "Disabling profiles..."
|
371
|
+
return
|
372
|
+
end
|
373
|
+
|
374
|
+
@profiles << @default_profile if using_default_profile?
|
375
|
+
|
376
|
+
@profiles.each do |profile|
|
377
|
+
merge_with_profile(profile)
|
378
|
+
end
|
379
|
+
|
380
|
+
@options[:profiles] = @profiles
|
381
|
+
end
|
382
|
+
|
383
|
+
def merge_with_profile(profile)
|
384
|
+
profile_args = profile_loader.args_from(profile)
|
385
|
+
profile_options = Options.parse(
|
386
|
+
profile_args, @out_stream, @error_stream,
|
387
|
+
:skip_profile_information => true,
|
388
|
+
:profile_loader => profile_loader
|
389
|
+
)
|
390
|
+
reverse_merge(profile_options)
|
391
|
+
end
|
392
|
+
|
393
|
+
def using_default_profile?
|
394
|
+
@profiles.empty? &&
|
395
|
+
profile_loader.lucid_yml_defined? &&
|
396
|
+
profile_loader.has_profile?(@default_profile)
|
397
|
+
end
|
398
|
+
|
399
|
+
def profile_loader
|
400
|
+
@profile_loader ||= Profile.new
|
401
|
+
end
|
402
|
+
|
403
|
+
def reverse_merge(other_options)
|
404
|
+
@options = other_options.options.merge(@options)
|
405
|
+
@options[:require] += other_options[:require]
|
406
|
+
@options[:excludes] += other_options[:excludes]
|
407
|
+
@options[:name_regexps] += other_options[:name_regexps]
|
408
|
+
@options[:tag_expressions] += other_options[:tag_expressions]
|
409
|
+
@options[:env_vars] = other_options[:env_vars].merge(@options[:env_vars])
|
410
|
+
if @options[:spec_source].empty?
|
411
|
+
@options[:spec_source] = other_options[:spec_source]
|
412
|
+
else
|
413
|
+
@overridden_paths += (other_options[:spec_source] - @options[:spec_source])
|
414
|
+
end
|
415
|
+
@options[:source] &= other_options[:source]
|
416
|
+
@options[:matchers] &= other_options[:matchers]
|
417
|
+
@options[:strict] |= other_options[:strict]
|
418
|
+
@options[:dry_run] |= other_options[:dry_run]
|
419
|
+
|
420
|
+
@profiles += other_options.profiles
|
421
|
+
@expanded_args += other_options.expanded_args
|
422
|
+
|
423
|
+
if @options[:formats].empty?
|
424
|
+
@options[:formats] = other_options[:formats]
|
425
|
+
else
|
426
|
+
@options[:formats] += other_options[:formats]
|
427
|
+
@options[:formats] = stdout_formats[0..0] + non_stdout_formats
|
428
|
+
end
|
429
|
+
|
430
|
+
self
|
431
|
+
end
|
432
|
+
|
433
|
+
def list_keywords_and_exit(lang)
|
434
|
+
require 'gherkin/i18n'
|
435
|
+
@out_stream.write(Gherkin::I18n.get(lang).keyword_table)
|
436
|
+
Kernel.exit(0)
|
437
|
+
end
|
438
|
+
|
439
|
+
def list_languages_and_exit
|
440
|
+
require 'gherkin/i18n'
|
441
|
+
@out_stream.write(Gherkin::I18n.language_table)
|
442
|
+
Kernel.exit(0)
|
443
|
+
end
|
444
|
+
|
445
|
+
def default_options
|
446
|
+
{
|
447
|
+
:strict => false,
|
448
|
+
:require => [],
|
449
|
+
:dry_run => false,
|
450
|
+
:formats => [],
|
451
|
+
:excludes => [],
|
452
|
+
:tag_expressions => [],
|
453
|
+
:name_regexps => [],
|
454
|
+
:env_vars => {},
|
455
|
+
:diff_enabled => true,
|
456
|
+
:spec_type => "",
|
457
|
+
:library_path => ""
|
458
|
+
}
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
end
|
463
|
+
end
|