aslakhellesoy-cucumber 0.1.99.3 → 0.1.99.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +6 -0
- metadata +1 -1
- data/cucumber.yml +0 -1
- data/examples/cs/README.textile +0 -1
- data/examples/cs/Rakefile +0 -12
- data/examples/cs/compile.bat +0 -1
- data/examples/cs/features/addition.feature +0 -16
- data/examples/cs/features/step_definitons/calculator_steps.rb +0 -19
- data/examples/cs/src/demo/Calculator.cs +0 -20
- data/examples/dos_line_endings/Rakefile +0 -6
- data/examples/dos_line_endings/features/dos_line_endings.feature +0 -9
- data/examples/i18n/README.textile +0 -18
- data/examples/i18n/Rakefile +0 -32
- data/examples/i18n/ar/Rakefile +0 -6
- data/examples/i18n/ar/features/addition.feature +0 -17
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +0 -28
- data/examples/i18n/ar/lib/calculator.rb +0 -10
- data/examples/i18n/da/Rakefile +0 -6
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +0 -24
- data/examples/i18n/da/features/summering.feature +0 -17
- data/examples/i18n/da/lib/kalkulator.rb +0 -11
- data/examples/i18n/de/Rakefile +0 -6
- data/examples/i18n/de/features/addition.feature +0 -16
- data/examples/i18n/de/features/division.feature +0 -9
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +0 -24
- data/examples/i18n/de/lib/calculator.rb +0 -14
- data/examples/i18n/en/Rakefile +0 -6
- data/examples/i18n/en/features/addition.feature +0 -16
- data/examples/i18n/en/features/division.feature +0 -9
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +0 -24
- data/examples/i18n/en/lib/calculator.rb +0 -14
- data/examples/i18n/es/Rakefile +0 -6
- data/examples/i18n/es/features/adicion.feature +0 -17
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +0 -24
- data/examples/i18n/es/lib/calculador.rb +0 -11
- data/examples/i18n/et/Rakefile +0 -6
- data/examples/i18n/et/features/liitmine.feature +0 -17
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +0 -24
- data/examples/i18n/et/lib/kalkulaator.rb +0 -10
- data/examples/i18n/fi/Rakefile +0 -6
- data/examples/i18n/fi/features/jakolasku.feature +0 -9
- data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +0 -24
- data/examples/i18n/fi/features/yhteenlasku.feature +0 -16
- data/examples/i18n/fi/lib/laskin.rb +0 -14
- data/examples/i18n/fr/Rakefile +0 -6
- data/examples/i18n/fr/features/addition.feature +0 -15
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +0 -27
- data/examples/i18n/fr/lib/calculatrice.rb +0 -10
- data/examples/i18n/id/Rakefile +0 -6
- data/examples/i18n/id/features/addition.feature +0 -16
- data/examples/i18n/id/features/division.feature +0 -9
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +0 -24
- data/examples/i18n/id/lib/calculator.rb +0 -14
- data/examples/i18n/it/Rakefile +0 -6
- data/examples/i18n/it/features/somma.feature +0 -10
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +0 -24
- data/examples/i18n/it/lib/calcolatrice.rb +0 -11
- data/examples/i18n/ja/README.txt +0 -5
- data/examples/i18n/ja/Rakefile +0 -6
- data/examples/i18n/ja/features/addition.feature +0 -16
- data/examples/i18n/ja/features/division.feature +0 -9
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +0 -24
- data/examples/i18n/ja/lib/calculator.rb +0 -14
- data/examples/i18n/ko/Rakefile +0 -6
- data/examples/i18n/ko/features/addition.feature +0 -16
- data/examples/i18n/ko/features/division.feature +0 -10
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +0 -24
- data/examples/i18n/ko/lib/calculator.rb +0 -14
- data/examples/i18n/lt/Rakefile +0 -6
- data/examples/i18n/lt/features/addition.feature +0 -17
- data/examples/i18n/lt/features/division.feature +0 -9
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +0 -24
- data/examples/i18n/lt/lib/calculator.rb +0 -14
- data/examples/i18n/no/Rakefile +0 -6
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +0 -24
- data/examples/i18n/no/features/summering.feature +0 -18
- data/examples/i18n/no/lib/kalkulator.rb +0 -11
- data/examples/i18n/pt/Rakefile +0 -6
- data/examples/i18n/pt/features/adicao.feature +0 -10
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +0 -24
- data/examples/i18n/pt/lib/calculadora.rb +0 -10
- data/examples/i18n/ro/Rakefile +0 -6
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +0 -24
- data/examples/i18n/ro/features/suma.feature +0 -10
- data/examples/i18n/ro/lib/calculator.rb +0 -11
- data/examples/i18n/se/Rakefile +0 -6
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +0 -24
- data/examples/i18n/se/features/summering.feature +0 -17
- data/examples/i18n/se/lib/kalkulator.rb +0 -11
- data/examples/i18n/zh-CN/Rakefile +0 -6
- data/examples/i18n/zh-CN/features/addition.feature +0 -17
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +0 -26
- data/examples/i18n/zh-CN/lib/calculator.rb +0 -10
- data/examples/java/README.textile +0 -22
- data/examples/java/Rakefile +0 -12
- data/examples/java/features/hello.feature +0 -11
- data/examples/java/features/step_definitons/hello_steps.rb +0 -25
- data/examples/java/features/step_definitons/tree_steps.rb +0 -14
- data/examples/java/features/tree.feature +0 -9
- data/examples/jbehave/README.textile +0 -17
- data/examples/jbehave/features/support/env.rb +0 -7
- data/examples/jbehave/features/trading.feature +0 -24
- data/examples/jbehave/pom.xml +0 -48
- data/examples/selenium/Rakefile +0 -6
- data/examples/selenium/features/search.feature +0 -9
- data/examples/selenium/features/step_definitons/stories_steps.rb +0 -40
- data/examples/self_test/README.textile +0 -6
- data/examples/self_test/features/call_undefined_step_from_step_def.feature +0 -7
- data/examples/self_test/features/lots_of_undefined.feature +0 -8
- data/examples/self_test/features/outline_sample.feature +0 -12
- data/examples/self_test/features/sample.feature +0 -16
- data/examples/self_test/features/step_definitions/sample_steps.rb +0 -25
- data/examples/test_unit/Rakefile +0 -6
- data/examples/test_unit/features/step_definitions/test_unit_steps.rb +0 -26
- data/examples/test_unit/features/test_unit.feature +0 -9
- data/examples/tickets/Rakefile +0 -11
- data/examples/tickets/cucumber.yml +0 -2
- data/examples/tickets/features/lib/eatting_machine.rb +0 -18
- data/examples/tickets/features/lib/pantry.rb +0 -20
- data/examples/tickets/features/scenario_outline.feature +0 -90
- data/examples/tickets/features/step_definitons/scenario_outline_steps.rb +0 -42
- data/examples/tickets/features/step_definitons/tickets_steps.rb +0 -61
- data/examples/tickets/features/tickets.feature +0 -28
- data/examples/watir/README.textile +0 -16
- data/examples/watir/Rakefile +0 -6
- data/examples/watir/features/search.feature +0 -9
- data/examples/watir/features/step_definitons/search_steps.rb +0 -24
- data/examples/watir/features/support/env.rb +0 -32
- data/features/cucumber_cli.feature +0 -327
- data/features/cucumber_cli_outlines.feature +0 -81
- data/features/report_called_undefined_steps.feature +0 -32
- data/features/step_definitions/cucumber_steps.rb +0 -31
- data/features/step_definitions/extra_steps.rb +0 -2
- data/features/support/env.rb +0 -7
- data/gem_tasks/deployment.rake +0 -11
- data/gem_tasks/environment.rake +0 -7
- data/gem_tasks/features.rake +0 -6
- data/gem_tasks/fix_cr_lf.rake +0 -10
- data/gem_tasks/flog.rake +0 -4
- data/gem_tasks/gemspec.rake +0 -10
- data/gem_tasks/rspec.rake +0 -35
- data/gem_tasks/yard.rake +0 -8
- data/lib/autotest/cucumber.rb +0 -6
- data/lib/autotest/cucumber_mixin.rb +0 -124
- data/lib/autotest/cucumber_rails.rb +0 -6
- data/lib/autotest/cucumber_rails_rspec.rb +0 -6
- data/lib/autotest/cucumber_rspec.rb +0 -6
- data/lib/autotest/discover.rb +0 -9
- data/lib/cucumber/ast/comment.rb +0 -26
- data/lib/cucumber/ast/examples.rb +0 -22
- data/lib/cucumber/ast/feature.rb +0 -60
- data/lib/cucumber/ast/features.rb +0 -39
- data/lib/cucumber/ast/filter.rb +0 -22
- data/lib/cucumber/ast/outline_table.rb +0 -49
- data/lib/cucumber/ast/py_string.rb +0 -52
- data/lib/cucumber/ast/scenario.rb +0 -95
- data/lib/cucumber/ast/scenario_outline.rb +0 -83
- data/lib/cucumber/ast/step.rb +0 -139
- data/lib/cucumber/ast/table.rb +0 -214
- data/lib/cucumber/ast/tags.rb +0 -33
- data/lib/cucumber/ast/visitor.rb +0 -93
- data/lib/cucumber/ast.rb +0 -27
- data/lib/cucumber/broadcaster.rb +0 -15
- data/lib/cucumber/cli.rb +0 -410
- data/lib/cucumber/core_ext/exception.rb +0 -53
- data/lib/cucumber/core_ext/instance_exec.rb +0 -54
- data/lib/cucumber/core_ext/proc.rb +0 -33
- data/lib/cucumber/core_ext/string.rb +0 -48
- data/lib/cucumber/formatter/ansicolor.rb +0 -106
- data/lib/cucumber/formatter/console.rb +0 -116
- data/lib/cucumber/formatter/pretty.rb +0 -158
- data/lib/cucumber/formatter/profile.rb +0 -77
- data/lib/cucumber/formatter/progress.rb +0 -68
- data/lib/cucumber/formatter/rerun.rb +0 -35
- data/lib/cucumber/formatter.rb +0 -1
- data/lib/cucumber/formatters/autotest_formatter.rb +0 -21
- data/lib/cucumber/formatters/cucumber.css +0 -132
- data/lib/cucumber/formatters/cucumber.js +0 -11
- data/lib/cucumber/formatters/html_formatter.rb +0 -152
- data/lib/cucumber/formatters/jquery.js +0 -32
- data/lib/cucumber/formatters/pretty_formatter.rb +0 -285
- data/lib/cucumber/formatters/unicode.rb +0 -35
- data/lib/cucumber/jbehave.rb +0 -104
- data/lib/cucumber/languages.yml +0 -314
- data/lib/cucumber/parser/basic.rb +0 -0
- data/lib/cucumber/parser/feature.rb +0 -1315
- data/lib/cucumber/parser/feature.tt +0 -160
- data/lib/cucumber/parser/i18n.tt +0 -27
- data/lib/cucumber/parser/table.rb +0 -396
- data/lib/cucumber/parser/table.tt +0 -53
- data/lib/cucumber/parser/treetop_ext.rb +0 -67
- data/lib/cucumber/parser.rb +0 -24
- data/lib/cucumber/platform.rb +0 -18
- data/lib/cucumber/rails/rspec.rb +0 -5
- data/lib/cucumber/rails/world.rb +0 -73
- data/lib/cucumber/rake/task.rb +0 -106
- data/lib/cucumber/step_definition.rb +0 -87
- data/lib/cucumber/step_mother.rb +0 -164
- data/lib/cucumber/treetop_parser/feature_fi.rb +0 -1951
- data/lib/cucumber/version.rb +0 -10
- data/lib/cucumber.rb +0 -72
- data/pretty.txt +0 -486
- data/rails_generators/cucumber/USAGE +0 -11
- data/rails_generators/cucumber/cucumber_generator.rb +0 -31
- data/rails_generators/cucumber/templates/cucumber +0 -8
- data/rails_generators/cucumber/templates/cucumber.rake +0 -7
- data/rails_generators/cucumber/templates/env.rb +0 -16
- data/rails_generators/cucumber/templates/paths.rb +0 -12
- data/rails_generators/cucumber/templates/webrat_steps.rb +0 -99
- data/rails_generators/feature/USAGE +0 -12
- data/rails_generators/feature/feature_generator.rb +0 -36
- data/rails_generators/feature/templates/feature.erb +0 -31
- data/rails_generators/feature/templates/steps.erb +0 -24
- data/spec/cucumber/ast/feature_factory.rb +0 -54
- data/spec/cucumber/ast/feature_spec.rb +0 -60
- data/spec/cucumber/ast/py_string_spec.rb +0 -40
- data/spec/cucumber/ast/scenario_outline_spec.rb +0 -64
- data/spec/cucumber/ast/scenario_spec.rb +0 -82
- data/spec/cucumber/ast/step_spec.rb +0 -45
- data/spec/cucumber/ast/table_spec.rb +0 -81
- data/spec/cucumber/broadcaster_spec.rb +0 -14
- data/spec/cucumber/cli_spec.rb +0 -416
- data/spec/cucumber/core_ext/proc_spec.rb +0 -37
- data/spec/cucumber/core_ext/string_spec.rb +0 -42
- data/spec/cucumber/formatter/ansicolor_spec.rb +0 -35
- data/spec/cucumber/formatter/html/cucumber.css +0 -37
- data/spec/cucumber/formatter/html/cucumber.js +0 -11
- data/spec/cucumber/formatter/html/index.html +0 -45
- data/spec/cucumber/formatter/html/jquery-1.3.min.js +0 -19
- data/spec/cucumber/formatter/html/jquery.uitableedit.js +0 -100
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +0 -27
- data/spec/cucumber/formatters/features.html +0 -269
- data/spec/cucumber/formatters/profile_formatter_spec.rb +0 -198
- data/spec/cucumber/parser/feature_parser_spec.rb +0 -247
- data/spec/cucumber/parser/table_parser_spec.rb +0 -48
- data/spec/cucumber/rails/stubs/mini_rails.rb +0 -18
- data/spec/cucumber/rails/stubs/test_help.rb +0 -1
- data/spec/cucumber/rails/world_spec.rb +0 -11
- data/spec/cucumber/sell_cucumbers.feature +0 -19
- data/spec/cucumber/step_definition_spec.rb +0 -62
- data/spec/cucumber/step_mom_spec.rb +0 -49
- data/spec/cucumber/treetop_parser/empty_feature.feature +0 -4
- data/spec/cucumber/treetop_parser/empty_scenario.feature +0 -9
- data/spec/cucumber/treetop_parser/empty_scenario_outline.feature +0 -3
- data/spec/cucumber/treetop_parser/fit_scenario.feature +0 -8
- data/spec/cucumber/treetop_parser/given_scenario.feature +0 -9
- data/spec/cucumber/treetop_parser/invalid_scenario_outlines.feature +0 -7
- data/spec/cucumber/treetop_parser/multiline_steps.feature +0 -17
- data/spec/cucumber/treetop_parser/multiple_tables.feature +0 -27
- data/spec/cucumber/treetop_parser/scenario_outline.feature +0 -16
- data/spec/cucumber/treetop_parser/spaces.feature +0 -12
- data/spec/cucumber/treetop_parser/test_dos.feature +0 -25
- data/spec/cucumber/treetop_parser/with_comments.feature +0 -10
- data/spec/cucumber/treetop_parser/with_tags.feature +0 -18
- data/spec/cucumber/world/pending_spec.rb +0 -47
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -21
data/lib/cucumber/cli.rb
DELETED
@@ -1,410 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'cucumber'
|
3
|
-
require 'ostruct'
|
4
|
-
require 'cucumber/parser'
|
5
|
-
require 'cucumber/formatter'
|
6
|
-
|
7
|
-
module Cucumber
|
8
|
-
class YmlLoadError < StandardError; end
|
9
|
-
|
10
|
-
class CLI
|
11
|
-
class << self
|
12
|
-
def step_mother=(step_mother)
|
13
|
-
@step_mother = step_mother
|
14
|
-
@step_mother.extend(StepMother)
|
15
|
-
@step_mother.snippet_generator = StepDefinition
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute(args)
|
19
|
-
parse(args).execute!(@step_mother)
|
20
|
-
end
|
21
|
-
|
22
|
-
def parse(args)
|
23
|
-
cli = new
|
24
|
-
cli.parse_options!(args)
|
25
|
-
cli
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
attr_reader :options, :paths
|
30
|
-
FORMATS = %w{pretty profile progress rerun}
|
31
|
-
DEFAULT_FORMAT = 'pretty'
|
32
|
-
|
33
|
-
def initialize(out_stream = STDOUT, error_stream = STDERR)
|
34
|
-
@out_stream = out_stream
|
35
|
-
|
36
|
-
@error_stream = error_stream
|
37
|
-
@paths = []
|
38
|
-
@options = {
|
39
|
-
:strict => false,
|
40
|
-
:require => nil,
|
41
|
-
:lang => 'en',
|
42
|
-
:dry_run => false,
|
43
|
-
:formats => {},
|
44
|
-
:excludes => [],
|
45
|
-
:tags => [],
|
46
|
-
:scenario_names => []
|
47
|
-
}
|
48
|
-
@active_format = DEFAULT_FORMAT
|
49
|
-
end
|
50
|
-
|
51
|
-
def parse_options!(args)
|
52
|
-
@args = args
|
53
|
-
return parse_args_from_profile('default') if args.empty?
|
54
|
-
args.extend(OptionParser::Arguable)
|
55
|
-
|
56
|
-
args.options do |opts|
|
57
|
-
opts.banner = ["Usage: cucumber [options] [[FILE[:LINE[:LINE]*]] | [FILES|DIRS]]", "",
|
58
|
-
"Examples:",
|
59
|
-
"cucumber examples/i18n/en/features",
|
60
|
-
"cucumber --language it examples/i18n/it/features/somma.feature:6:98:113", "", ""
|
61
|
-
].join("\n")
|
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.",
|
70
|
-
"This option can be specified multiple times.") do |v|
|
71
|
-
@options[:require] ||= []
|
72
|
-
@options[:require] << v
|
73
|
-
end
|
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(v)
|
82
|
-
else
|
83
|
-
@options[:lang] = v
|
84
|
-
end
|
85
|
-
end
|
86
|
-
opts.on("-f FORMAT", "--format FORMAT",
|
87
|
-
"How to format features (Default: #{DEFAULT_FORMAT})",
|
88
|
-
"Available formats: #{FORMATS.join(", ")}",
|
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.",
|
93
|
-
"This option can be specified multiple times.") do |v|
|
94
|
-
@options[:formats][v] = @out_stream
|
95
|
-
@active_format = v
|
96
|
-
end
|
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(",")
|
107
|
-
end
|
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
|
112
|
-
end
|
113
|
-
opts.on("-e", "--exclude PATTERN", "Don't run feature files matching PATTERN") do |v|
|
114
|
-
@options[:excludes] << v
|
115
|
-
end
|
116
|
-
opts.on("-p", "--profile PROFILE", "Pull commandline arguments from cucumber.yml.") do |v|
|
117
|
-
parse_args_from_profile(v)
|
118
|
-
end
|
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
|
135
|
-
@options[:dry_run] = true
|
136
|
-
@quiet = true
|
137
|
-
end
|
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
|
141
|
-
end
|
142
|
-
opts.on("-i", "--[no-]snippets", "Don't show the snippets for pending steps.") do |v|
|
143
|
-
@options[:snippets] = v
|
144
|
-
end
|
145
|
-
opts.on("-q", "--quiet", "Alias for --no-snippets --no-source.") do
|
146
|
-
@quiet = true
|
147
|
-
end
|
148
|
-
opts.on("-b", "--backtrace", "Show full backtrace for all errors.") do
|
149
|
-
Exception.cucumber_full_backtrace = true
|
150
|
-
end
|
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
|
155
|
-
@options[:verbose] = true
|
156
|
-
end
|
157
|
-
opts.on_tail("--version", "Show version.") do
|
158
|
-
@out_stream.puts VERSION::STRING
|
159
|
-
Kernel.exit
|
160
|
-
end
|
161
|
-
opts.on_tail("--help", "You're looking at it.") do
|
162
|
-
@out_stream.puts opts.help
|
163
|
-
Kernel.exit
|
164
|
-
end
|
165
|
-
end.parse!
|
166
|
-
|
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
|
-
|
172
|
-
# Whatever is left after option parsing is the FILE arguments
|
173
|
-
@paths += args
|
174
|
-
end
|
175
|
-
|
176
|
-
|
177
|
-
def execute!(step_mother)
|
178
|
-
Cucumber.load_language(@options[:lang])
|
179
|
-
require_files
|
180
|
-
enable_diffing
|
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)
|
189
|
-
end
|
190
|
-
|
191
|
-
private
|
192
|
-
|
193
|
-
def cucumber_yml
|
194
|
-
return @cucumber_yml if @cucumber_yml
|
195
|
-
unless File.exist?('cucumber.yml')
|
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")
|
197
|
-
end
|
198
|
-
|
199
|
-
require 'yaml'
|
200
|
-
begin
|
201
|
-
@cucumber_yml = YAML::load(IO.read('cucumber.yml'))
|
202
|
-
rescue Exception => e
|
203
|
-
raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentaion on correct profile usage.\n")
|
204
|
-
end
|
205
|
-
|
206
|
-
if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
|
207
|
-
raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentaion on correct profile usage.\n")
|
208
|
-
end
|
209
|
-
|
210
|
-
return @cucumber_yml
|
211
|
-
end
|
212
|
-
|
213
|
-
def parse_args_from_profile(profile)
|
214
|
-
unless cucumber_yml.has_key?(profile)
|
215
|
-
return(exit_with_error <<-END_OF_ERROR)
|
216
|
-
Could not find profile: '#{profile}'
|
217
|
-
|
218
|
-
Defined profiles in cucumber.yml:
|
219
|
-
* #{cucumber_yml.keys.join("\n * ")}
|
220
|
-
END_OF_ERROR
|
221
|
-
end
|
222
|
-
|
223
|
-
args_from_yml = cucumber_yml[profile] || ''
|
224
|
-
|
225
|
-
if !args_from_yml.is_a?(String)
|
226
|
-
exit_with_error "Profiles must be defined as a String. The '#{profile}' profile was #{args_from_yml.inspect} (#{args_from_yml.class}).\n"
|
227
|
-
elsif args_from_yml =~ /^\s*$/
|
228
|
-
exit_with_error "The 'foo' profile in cucumber.yml was blank. Please define the command line arguments for the 'foo' profile in cucumber.yml.\n"
|
229
|
-
else
|
230
|
-
parse_options!(args_from_yml.split(' '))
|
231
|
-
end
|
232
|
-
|
233
|
-
rescue YmlLoadError => e
|
234
|
-
exit_with_error(e.message)
|
235
|
-
end
|
236
|
-
|
237
|
-
# Requires files - typically step files and ruby feature files.
|
238
|
-
def require_files
|
239
|
-
verbose_log("Ruby files required:")
|
240
|
-
files_to_require.each do |lib|
|
241
|
-
begin
|
242
|
-
require lib
|
243
|
-
verbose_log(" * #{lib}")
|
244
|
-
rescue LoadError => e
|
245
|
-
e.message << "\nFailed to load #{lib}"
|
246
|
-
raise e
|
247
|
-
end
|
248
|
-
end
|
249
|
-
verbose_log("\n")
|
250
|
-
end
|
251
|
-
|
252
|
-
def files_to_require
|
253
|
-
requires = @options[:require] || feature_dirs
|
254
|
-
files = requires.map do |path|
|
255
|
-
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
256
|
-
File.directory?(path) ? Dir["#{path}/**/*.rb"] : path
|
257
|
-
end.flatten.uniq
|
258
|
-
files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }
|
259
|
-
end
|
260
|
-
|
261
|
-
def feature_files
|
262
|
-
potential_feature_files = @paths.map do |path|
|
263
|
-
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
264
|
-
path = path.chomp('/')
|
265
|
-
File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
|
266
|
-
end.flatten.uniq
|
267
|
-
|
268
|
-
@options[:excludes].each do |exclude|
|
269
|
-
potential_feature_files.reject! do |path|
|
270
|
-
path =~ /#{Regexp.escape(exclude)}/
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
potential_feature_files
|
275
|
-
end
|
276
|
-
|
277
|
-
def feature_dirs
|
278
|
-
feature_files.map{|f| File.directory?(f) ? f : File.dirname(f)}.uniq
|
279
|
-
end
|
280
|
-
|
281
|
-
def load_plain_text_features
|
282
|
-
filter = Ast::Filter.new(@options)
|
283
|
-
features = Ast::Features.new(filter)
|
284
|
-
parser = Parser::FeatureParser.new
|
285
|
-
|
286
|
-
verbose_log("Features:")
|
287
|
-
feature_files.each do |f|
|
288
|
-
features.add_feature(parser.parse_file(f))
|
289
|
-
verbose_log(" * #{f}")
|
290
|
-
end
|
291
|
-
verbose_log("\n"*2)
|
292
|
-
features
|
293
|
-
end
|
294
|
-
|
295
|
-
def build_formatter_broadcaster(step_mother)
|
296
|
-
return Formatter::Pretty.new(step_mother, nil, @options) if @options[:autoformat]
|
297
|
-
formatters = @options[:formats].map do |format, out|
|
298
|
-
if String === out # file name
|
299
|
-
out = File.open(out, Cucumber.file_mode('w'))
|
300
|
-
at_exit do
|
301
|
-
out.flush
|
302
|
-
out.close
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
case format
|
307
|
-
when 'pretty'
|
308
|
-
Formatter::Pretty.new(step_mother, out, @options)
|
309
|
-
when 'progress'
|
310
|
-
Formatter::Progress.new(step_mother, out, @options)
|
311
|
-
when 'profile'
|
312
|
-
Formatter::Profile.new(step_mother, out, @options)
|
313
|
-
when 'rerun'
|
314
|
-
Formatter::Rerun.new(step_mother, out, @options)
|
315
|
-
else
|
316
|
-
begin
|
317
|
-
formatter_class = constantize(format)
|
318
|
-
formatter_class.new(step_mother, out, @options)
|
319
|
-
rescue Exception => e
|
320
|
-
exit_with_error("Error creating formatter: #{format}", e)
|
321
|
-
end
|
322
|
-
end
|
323
|
-
end
|
324
|
-
Broadcaster.new(formatters)
|
325
|
-
end
|
326
|
-
|
327
|
-
def constantize(camel_cased_word)
|
328
|
-
names = camel_cased_word.split('::')
|
329
|
-
names.shift if names.empty? || names.first.empty?
|
330
|
-
|
331
|
-
constant = Object
|
332
|
-
names.each do |name|
|
333
|
-
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
334
|
-
end
|
335
|
-
constant
|
336
|
-
end
|
337
|
-
|
338
|
-
def verbose_log(string)
|
339
|
-
@out_stream.puts(string) if @options[:verbose]
|
340
|
-
end
|
341
|
-
|
342
|
-
def exit_with_help
|
343
|
-
parse_options!(%w{--help})
|
344
|
-
end
|
345
|
-
|
346
|
-
def exit_with_error(error_message, e=nil)
|
347
|
-
@error_stream.puts(error_message)
|
348
|
-
if e
|
349
|
-
@error_stream.puts("#{e.message} (#{e.class})")
|
350
|
-
@error_stream.puts(e.backtrace.join("\n"))
|
351
|
-
end
|
352
|
-
Kernel.exit 1
|
353
|
-
end
|
354
|
-
|
355
|
-
def enable_diffing
|
356
|
-
if defined?(::Spec)
|
357
|
-
require 'spec/expectations/differs/default'
|
358
|
-
options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
|
359
|
-
::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
def list_languages
|
364
|
-
raw = Cucumber::LANGUAGES.keys.sort.map do |lang|
|
365
|
-
[lang, Cucumber::LANGUAGES[lang]['name'], Cucumber::LANGUAGES[lang]['native']]
|
366
|
-
end
|
367
|
-
print_lang_table(raw, {:check_lang=>true})
|
368
|
-
end
|
369
|
-
|
370
|
-
def list_keywords(lang)
|
371
|
-
unless Cucumber::LANGUAGES[lang]
|
372
|
-
exit_with_error("No language with key #{v}")
|
373
|
-
end
|
374
|
-
raw = Cucumber::KEYWORD_KEYS.map do |key|
|
375
|
-
[key, Cucumber::LANGUAGES[lang][key]]
|
376
|
-
end
|
377
|
-
print_lang_table(raw, {})
|
378
|
-
end
|
379
|
-
|
380
|
-
def print_lang_table(raw, options)
|
381
|
-
table = Ast::Table.new(raw)
|
382
|
-
formatter = Formatter::Pretty.new(nil, @out_stream, options, '')
|
383
|
-
|
384
|
-
def formatter.visit_table_row(table_row, status)
|
385
|
-
@col = 1
|
386
|
-
super
|
387
|
-
end
|
388
|
-
|
389
|
-
def formatter.visit_table_cell_value(value, width, status)
|
390
|
-
if @col == 1
|
391
|
-
if(@options[:check_lang])
|
392
|
-
@incomplete = Cucumber.language_complete?(value)
|
393
|
-
end
|
394
|
-
status = :comment
|
395
|
-
elsif @incomplete
|
396
|
-
status = :failed
|
397
|
-
end
|
398
|
-
|
399
|
-
@col += 1
|
400
|
-
super(value, width, status)
|
401
|
-
end
|
402
|
-
|
403
|
-
formatter.indent = 0
|
404
|
-
formatter.visit_multiline_arg(table, :passed)
|
405
|
-
Kernel.exit
|
406
|
-
end
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
Cucumber::CLI.step_mother = self
|
@@ -1,53 +0,0 @@
|
|
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
|
-
#
|
21
|
-
class Exception
|
22
|
-
CUCUMBER_FILTER_PATTERNS = [
|
23
|
-
/vendor\/rails|lib\/cucumber|lib\/rspec|gems\//
|
24
|
-
]
|
25
|
-
|
26
|
-
INSTANCE_EXEC_OFFSET = (Cucumber::RUBY_1_9 || Cucumber::JRUBY) ? -3 : -4
|
27
|
-
|
28
|
-
def self.cucumber_full_backtrace=(v)
|
29
|
-
@@cucumber_full_backtrace = v
|
30
|
-
end
|
31
|
-
self.cucumber_full_backtrace = false
|
32
|
-
|
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|
|
50
|
-
CUCUMBER_FILTER_PATTERNS.detect{|p| line =~ p}
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,54 +0,0 @@
|
|
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
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Proc extension to get more location info out of a proc
|
2
|
-
class Proc
|
3
|
-
PROC_PATTERN = /[\d\w]+@(.*):(.*)>/
|
4
|
-
|
5
|
-
if Proc.new{}.to_s =~ PROC_PATTERN
|
6
|
-
def to_backtrace_line(name)
|
7
|
-
"#{file_colon_line}:in `#{name}'"
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_comment_line
|
11
|
-
"# #{file_colon_line}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def file_colon_line
|
15
|
-
path, line = *to_s.match(PROC_PATTERN)[1..2]
|
16
|
-
path = File.expand_path(path)
|
17
|
-
pwd = Dir.pwd
|
18
|
-
path = path[pwd.length+1..-1]
|
19
|
-
"#{path}:#{line}"
|
20
|
-
end
|
21
|
-
else
|
22
|
-
# This Ruby implementation doesn't implement Proc#to_s correctly
|
23
|
-
STDERR.puts "*** THIS RUBY IMPLEMENTATION DOESN'T REPORT FILE AND LINE FOR PROCS ***"
|
24
|
-
|
25
|
-
def to_backtrace_line
|
26
|
-
nil
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_comment_line
|
30
|
-
""
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
def indent(n)
|
3
|
-
if n >= 0
|
4
|
-
gsub(/^/, ' ' * n)
|
5
|
-
else
|
6
|
-
gsub(/^ {0,#{-n}}/, "")
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
# re.source.gsub(/\([^)]*\)/, '$var')
|
11
|
-
# Cumulative #sub
|
12
|
-
def subs(re, *args)
|
13
|
-
args.inject(self) do |s,arg|
|
14
|
-
s.sub(re, arg)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# TODO: Use subs instead...
|
19
|
-
def gzub(regexp, format=nil, &proc)
|
20
|
-
md = match(regexp)
|
21
|
-
raise "#{self.inspect} doesn't match #{regexp.inspect}" if md.nil?
|
22
|
-
|
23
|
-
s = dup
|
24
|
-
pos = 0
|
25
|
-
md.captures.each_with_index do |m, n|
|
26
|
-
replacement = if block_given?
|
27
|
-
proc.call(m)
|
28
|
-
elsif Proc === format
|
29
|
-
format.call(m)
|
30
|
-
else
|
31
|
-
format % m
|
32
|
-
end
|
33
|
-
|
34
|
-
if md.offset(n+1)[0]
|
35
|
-
s[md.offset(n+1)[0] + pos, m.length] = replacement
|
36
|
-
pos += replacement.length - m.length
|
37
|
-
end
|
38
|
-
end
|
39
|
-
s
|
40
|
-
end
|
41
|
-
|
42
|
-
if (Cucumber::JRUBY && Cucumber::RAILS) || Cucumber::RUBY_1_9
|
43
|
-
# Workaround for http://tinyurl.com/55uu3u
|
44
|
-
alias jlength length
|
45
|
-
else
|
46
|
-
require 'jcode'
|
47
|
-
end
|
48
|
-
end
|