kosmas58-cucumber 0.1.16.6 → 0.1.99.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +126 -2
- data/License.txt +1 -1
- data/Manifest.txt +0 -270
- data/Rakefile +1 -1
- data/bin/cucumber +2 -2
- data/config/hoe.rb +7 -2
- data/examples/cs/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/README.textile +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/adicion.feature +11 -12
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +7 -10
- data/examples/i18n/es/lib/calculador.rb +4 -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/java/src/cucumber/demo/Hello.java +16 -0
- 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/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java +32 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java +42 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java +29 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java +22 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +65 -0
- data/examples/self_test/README.textile +4 -1
- data/examples/{calculator_ruby_features → self_test}/Rakefile +3 -3
- data/examples/self_test/features/background/failing_background.feature +10 -0
- data/examples/self_test/features/background/failing_background_after_success.feature +11 -0
- data/examples/self_test/features/background/multiline_args_background.feature +32 -0
- data/examples/self_test/features/background/passing_background.feature +10 -0
- data/examples/self_test/features/background/pending_background.feature +10 -0
- data/examples/self_test/features/background/scenario_outline_failing_background.feature +16 -0
- data/examples/self_test/features/background/scenario_outline_passing_background.feature +16 -0
- 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 +11 -5
- data/examples/self_test/features/sample.feature +8 -3
- data/examples/self_test/features/step_definitions/sample_steps.rb +53 -4
- data/examples/self_test/features/support/env.rb +1 -0
- data/examples/self_test/features/support/tag_count_formatter.rb +25 -0
- data/examples/tickets/features/172.feature +28 -0
- data/examples/tickets/features/177/1.feature +29 -0
- data/examples/tickets/features/177/2.feature +21 -0
- data/examples/tickets/features/177/3.feature +18 -0
- data/examples/tickets/features/180.feature +7 -0
- data/examples/tickets/features/scenario_outline.feature +6 -1
- data/examples/tickets/features/step_definitons/tickets_steps.rb +27 -3
- data/examples/tickets/features/tickets.feature +4 -0
- data/features/background.feature +223 -0
- data/features/cucumber_cli.feature +218 -98
- data/features/cucumber_cli_outlines.feature +54 -37
- data/features/custom_formatter.feature +11 -0
- data/features/report_called_undefined_steps.feature +32 -0
- data/features/step_definitions/cucumber_steps.rb +7 -3
- data/features/step_definitions/extra_steps.rb +1 -1
- data/features/support/env.rb +2 -1
- data/gem_tasks/flog.rake +1 -1
- data/gem_tasks/gemspec.rake +2 -2
- data/gem_tasks/jar.rake +67 -0
- data/lib/autotest/cucumber_mixin.rb +17 -23
- data/lib/cucumber.rb +63 -11
- data/lib/cucumber/ast.rb +29 -0
- data/lib/cucumber/ast/background.rb +88 -0
- data/lib/cucumber/ast/comment.rb +26 -0
- data/lib/cucumber/ast/examples.rb +26 -0
- data/lib/cucumber/ast/feature.rb +66 -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 +103 -0
- data/lib/cucumber/ast/scenario_outline.rb +92 -0
- data/lib/cucumber/ast/step.rb +161 -0
- data/lib/cucumber/ast/steps.rb +13 -0
- data/lib/cucumber/ast/table.rb +218 -0
- data/lib/cucumber/ast/tags.rb +40 -0
- data/lib/cucumber/ast/visitor.rb +109 -0
- data/lib/cucumber/broadcaster.rb +1 -6
- data/lib/cucumber/cli/configuration.rb +339 -0
- data/lib/cucumber/cli/language_help_formatter.rb +59 -0
- data/lib/cucumber/cli/main.rb +100 -0
- 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/formatter.rb +1 -0
- data/lib/cucumber/{formatters → formatter}/ansicolor.rb +14 -16
- data/lib/cucumber/formatter/color_io.rb +17 -0
- data/lib/cucumber/formatter/console.rb +119 -0
- data/lib/cucumber/formatter/cucumber.css +55 -0
- data/lib/cucumber/formatter/cucumber.sass +49 -0
- data/lib/cucumber/formatter/html.rb +121 -0
- data/lib/cucumber/formatter/pretty.rb +167 -0
- data/lib/cucumber/formatter/profile.rb +77 -0
- data/lib/cucumber/formatter/progress.rb +68 -0
- data/lib/cucumber/formatter/rerun.rb +35 -0
- data/lib/cucumber/formatter/unicode.rb +35 -0
- data/lib/cucumber/formatters/unicode.rb +2 -35
- data/lib/cucumber/jbehave.rb +102 -0
- data/lib/cucumber/languages.yml +128 -75
- data/lib/cucumber/parser.rb +43 -0
- data/lib/cucumber/parser/basic.rb +0 -0
- data/lib/cucumber/parser/feature.rb +1490 -0
- data/lib/cucumber/parser/feature.tt +188 -0
- data/lib/cucumber/parser/i18n.tt +31 -0
- data/lib/cucumber/parser/table.rb +402 -0
- data/lib/cucumber/parser/table.tt +59 -0
- data/lib/cucumber/parser/treetop_ext.rb +75 -0
- data/lib/cucumber/platform.rb +3 -17
- data/lib/cucumber/rails/rspec.rb +5 -2
- data/lib/cucumber/step_definition.rb +87 -0
- data/lib/cucumber/step_mother.rb +151 -66
- data/lib/cucumber/version.rb +2 -2
- data/rails_generators/cucumber/USAGE +3 -2
- data/rails_generators/cucumber/cucumber_generator.rb +33 -23
- data/rails_generators/cucumber/templates/cucumber +2 -1
- data/rails_generators/cucumber/templates/cucumber.rake +6 -1
- data/rails_generators/cucumber/templates/env.rb +1 -1
- data/rails_generators/feature/USAGE +3 -0
- data/rails_generators/feature/feature_generator.rb +30 -6
- data/spec/cucumber/ast/background_spec.rb +58 -0
- 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/ast/tags_spec.rb +23 -0
- data/spec/cucumber/broadcaster_spec.rb +4 -17
- data/spec/cucumber/cli/configuration_spec.rb +239 -0
- data/spec/cucumber/cli/main_spec.rb +164 -0
- 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 +13 -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/profile_formatter_spec.rb +17 -16
- data/spec/cucumber/parser/feature_parser_spec.rb +281 -0
- data/spec/cucumber/parser/table_parser_spec.rb +48 -0
- data/spec/cucumber/step_definition_spec.rb +62 -0
- data/spec/cucumber/step_mother_spec.rb +50 -51
- data/spec/cucumber/treetop_parser/empty_feature.feature +1 -1
- data/spec/cucumber/treetop_parser/scenario_outline.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 +107 -79
- 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/cli.rb +0 -355
- data/lib/cucumber/executor.rb +0 -205
- data/lib/cucumber/formatters.rb +0 -1
- data/lib/cucumber/formatters/autotest_formatter.rb +0 -23
- 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/profile_formatter.rb +0 -92
- data/lib/cucumber/formatters/progress_formatter.rb +0 -61
- data/lib/cucumber/model.rb +0 -1
- data/lib/cucumber/model/table.rb +0 -32
- data/lib/cucumber/step_methods.rb +0 -49
- data/lib/cucumber/tree.rb +0 -16
- 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/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_fi.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.rb +0 -1
- data/lib/cucumber/world/pending.rb +0 -22
- data/setup.rb +0 -1585
- data/spec/cucumber/cli_spec.rb +0 -521
- data/spec/cucumber/executor_spec.rb +0 -382
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +0 -26
- data/spec/cucumber/formatters/features.html +0 -269
- data/spec/cucumber/formatters/html_formatter_spec.rb +0 -110
- 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/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
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'cucumber/cli' # Needed in order to run the feature with ruby
|
2
|
-
|
3
|
-
Feature %|Addition
|
4
|
-
In order to avoid silly mistakes
|
5
|
-
As a math idiot
|
6
|
-
I want to be told the sum of two numbers| do
|
7
|
-
|
8
|
-
Scenario "Add two numbers" do
|
9
|
-
Given "I have entered 50 into the calculator"
|
10
|
-
And "I have entered 70 into the calculator"
|
11
|
-
When "I add"
|
12
|
-
Then "the result should be 120 on the screen"
|
13
|
-
And "the result class should be Fixnum"
|
14
|
-
end
|
15
|
-
|
16
|
-
Table do |t|
|
17
|
-
t | "input_1" | "input_2" | "output" | "class" | t
|
18
|
-
# This is kind of dumb - but it illustrates how scenarios can be "generated" in code.
|
19
|
-
10.times do |n|
|
20
|
-
t | n | n*2 | n*3 | Fixnum | t
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
ScenarioOutline "Add two numbers" do
|
25
|
-
Given "I have entered <input_1> into the calculator"
|
26
|
-
And "I have entered <input_2> into the calculator"
|
27
|
-
When "I add"
|
28
|
-
Then "the result should be <output> on the screen"
|
29
|
-
And "the result class should be <class>"
|
30
|
-
end
|
31
|
-
|
32
|
-
Table do |t|
|
33
|
-
t | "input_1" | "input_2" | "output" | "class" | t
|
34
|
-
10.times do |n|
|
35
|
-
t | n | n*2 | n*3 | Fixnum | t
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec/expectations'
|
2
|
-
|
3
|
-
class Calculator
|
4
|
-
def push(n)
|
5
|
-
@args ||= []
|
6
|
-
@args << n
|
7
|
-
end
|
8
|
-
|
9
|
-
def add
|
10
|
-
@args.inject(0){|n,sum| sum+=n}
|
11
|
-
end
|
12
|
-
|
13
|
-
def divide
|
14
|
-
@args[0].to_f / @args[1].to_f
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Before do
|
19
|
-
@calc = Calculator.new
|
20
|
-
end
|
21
|
-
|
22
|
-
After do
|
23
|
-
end
|
24
|
-
|
25
|
-
Given /I have entered (\d+) into the calculator/ do |n|
|
26
|
-
@calc.push n.to_i
|
27
|
-
end
|
28
|
-
|
29
|
-
When 'I add' do
|
30
|
-
@result = @calc.add
|
31
|
-
end
|
32
|
-
|
33
|
-
When 'I divide' do
|
34
|
-
@result = @calc.divide
|
35
|
-
end
|
36
|
-
|
37
|
-
Then /the result should be (\d*) on the screen/ do |result|
|
38
|
-
@result.should == result.to_i
|
39
|
-
end
|
40
|
-
|
41
|
-
Then /the result class should be (\w*)/ do |class_name|
|
42
|
-
@result.class.name.should == class_name
|
43
|
-
end
|
data/gem_tasks/treetop.rake
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
class FeatureCompiler
|
2
|
-
def initialize
|
3
|
-
require 'yaml'
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
@tt = RUBY_PLATFORM =~ /mswin|mingw/ ? 'tt.bat' : 'tt'
|
7
|
-
|
8
|
-
@template = ERB.new(IO.read(File.dirname(__FILE__) + '/../lib/cucumber/treetop_parser/feature.treetop.erb'))
|
9
|
-
@langs = YAML.load_file(File.dirname(__FILE__) + '/../lib/cucumber/languages.yml')
|
10
|
-
end
|
11
|
-
|
12
|
-
def compile_all
|
13
|
-
@langs.keys.each do |lang|
|
14
|
-
compile(lang)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def compile(lang)
|
19
|
-
words = @langs['en'].merge(@langs[lang]) # Use English words if languages.yml is missing a word
|
20
|
-
grammar_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.treetop"
|
21
|
-
ruby_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.rb"
|
22
|
-
grammar = @template.result(binding)
|
23
|
-
File.open(grammar_file, "wb") do |io|
|
24
|
-
io.write(grammar)
|
25
|
-
end
|
26
|
-
sh "#{@tt} #{grammar_file}"
|
27
|
-
FileUtils.rm(grammar_file)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
namespace :treetop do
|
32
|
-
desc 'Compile the grammar for all languages in languages.yml'
|
33
|
-
task :compile do
|
34
|
-
FeatureCompiler.new.compile_all
|
35
|
-
end
|
36
|
-
|
37
|
-
desc 'Compile the English grammar'
|
38
|
-
task :compile_en do
|
39
|
-
FeatureCompiler.new.compile('en')
|
40
|
-
end
|
41
|
-
end
|
data/lib/cucumber/cli.rb
DELETED
@@ -1,355 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'cucumber'
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
|
-
module Cucumber
|
6
|
-
class YmlLoadError < StandardError; end
|
7
|
-
|
8
|
-
class CLI
|
9
|
-
class << self
|
10
|
-
attr_writer :step_mother, :executor, :features
|
11
|
-
|
12
|
-
def execute(args)
|
13
|
-
parse(args).execute!(@step_mother, @executor, @features)
|
14
|
-
end
|
15
|
-
|
16
|
-
def parse(args)
|
17
|
-
cli = new
|
18
|
-
cli.parse_options!(args)
|
19
|
-
cli
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_reader :options, :paths
|
24
|
-
FORMATS = %w{pretty profile progress html autotest}
|
25
|
-
DEFAULT_FORMAT = 'pretty'
|
26
|
-
|
27
|
-
def initialize(out_stream = STDOUT, error_stream = STDERR)
|
28
|
-
@out_stream = out_stream
|
29
|
-
@error_stream = error_stream
|
30
|
-
@paths = []
|
31
|
-
@options = {
|
32
|
-
:require => nil,
|
33
|
-
:lang => 'en',
|
34
|
-
:dry_run => false,
|
35
|
-
:source => true,
|
36
|
-
:snippets => true,
|
37
|
-
:formats => {},
|
38
|
-
:excludes => [],
|
39
|
-
:scenario_names => nil
|
40
|
-
}
|
41
|
-
@active_format = DEFAULT_FORMAT
|
42
|
-
end
|
43
|
-
|
44
|
-
def parse_options!(args)
|
45
|
-
@args = args
|
46
|
-
return parse_args_from_profile('default') if args.empty?
|
47
|
-
args.extend(OptionParser::Arguable)
|
48
|
-
|
49
|
-
args.options do |opts|
|
50
|
-
opts.banner = ["Usage: cucumber [options] [[FILE[:LINE[:LINE]*]] | [FILES|DIRS]]", "",
|
51
|
-
"Examples:",
|
52
|
-
"cucumber examples/i18n/en/features",
|
53
|
-
"cucumber --language it examples/i18n/it/features/somma.feature:6:98:113", "", ""
|
54
|
-
].join("\n")
|
55
|
-
opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR", "Require files before executing the features.",
|
56
|
-
"If this option is not specified, all *.rb files that",
|
57
|
-
"are siblings or below the features will be autorequired",
|
58
|
-
"This option can be specified multiple times.") do |v|
|
59
|
-
@options[:require] ||= []
|
60
|
-
@options[:require] << v
|
61
|
-
end
|
62
|
-
opts.on("-s SCENARIO", "--scenario SCENARIO", "Only execute the scenario with the given name.",
|
63
|
-
"If this option is given more than once, run all",
|
64
|
-
"the specified scenarios.") do |v|
|
65
|
-
@options[:scenario_names] ||= []
|
66
|
-
@options[:scenario_names] << v
|
67
|
-
end
|
68
|
-
opts.on("-l LANG", "--language LANG", "Specify language for features (Default: #{@options[:lang]})",
|
69
|
-
"Available languages: #{Cucumber.languages.join(", ")}",
|
70
|
-
"Look at #{Cucumber::LANGUAGE_FILE} for keywords") do |v|
|
71
|
-
@options[:lang] = v
|
72
|
-
end
|
73
|
-
opts.on("-f FORMAT", "--format FORMAT", "How to format features (Default: #{DEFAULT_FORMAT})",
|
74
|
-
"Available formats: #{FORMATS.join(", ")}",
|
75
|
-
"You can also provide your own formatter classes as long as they have been",
|
76
|
-
"previously required using --require or if they are in the folder",
|
77
|
-
"structure such that cucumber will require them automatically.",
|
78
|
-
"This option can be specified multiple times.") do |v|
|
79
|
-
|
80
|
-
@options[:formats][v] ||= []
|
81
|
-
@options[:formats][v] << @out_stream
|
82
|
-
@active_format = v
|
83
|
-
end
|
84
|
-
opts.on("-o", "--out FILE", "Write output to a file instead of @out_stream.",
|
85
|
-
"This option can be specified multiple times, and applies to the previously",
|
86
|
-
"specified --format.") do |v|
|
87
|
-
@options[:formats][@active_format] ||= []
|
88
|
-
if @options[:formats][@active_format].last == @out_stream
|
89
|
-
@options[:formats][@active_format][-1] = File.open(v, 'w')
|
90
|
-
else
|
91
|
-
@options[:formats][@active_format] << File.open(v, 'w')
|
92
|
-
end
|
93
|
-
end
|
94
|
-
opts.on("-c", "--[no-]color", "Use ANSI color in the output, if formatters use it. If",
|
95
|
-
"these options are given multiple times, the last one is",
|
96
|
-
"used. If neither --color or --no-color is given cucumber",
|
97
|
-
"decides based on your platform and the output destination") do |v|
|
98
|
-
@options[:color] = v
|
99
|
-
end
|
100
|
-
opts.on("-e", "--exclude PATTERN", "Don't run features matching a pattern") do |v|
|
101
|
-
@options[:excludes] << v
|
102
|
-
end
|
103
|
-
opts.on("-p", "--profile PROFILE", "Pull commandline arguments from cucumber.yml.") do |v|
|
104
|
-
parse_args_from_profile(v)
|
105
|
-
end
|
106
|
-
opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.") do
|
107
|
-
@options[:dry_run] = true
|
108
|
-
end
|
109
|
-
opts.on("-n", "--no-source", "Don't show the file and line of the step definition with the steps.") do
|
110
|
-
@options[:source] = false
|
111
|
-
end
|
112
|
-
opts.on("-i", "--no-snippets", "Don't show the snippets for pending steps") do
|
113
|
-
@options[:snippets] = false
|
114
|
-
end
|
115
|
-
opts.on("-q", "--quiet", "Don't show any development aid information") do
|
116
|
-
@options[:snippets] = false
|
117
|
-
@options[:source] = false
|
118
|
-
end
|
119
|
-
opts.on("-b", "--backtrace", "Show full backtrace for all errors") do
|
120
|
-
Exception.cucumber_full_backtrace = true
|
121
|
-
end
|
122
|
-
opts.on("-v", "--verbose", "Show the files and features loaded") do
|
123
|
-
@options[:verbose] = true
|
124
|
-
end
|
125
|
-
opts.on_tail("--version", "Show version") do
|
126
|
-
@out_stream.puts VERSION::STRING
|
127
|
-
Kernel.exit
|
128
|
-
end
|
129
|
-
opts.on_tail("--help", "You're looking at it") do
|
130
|
-
@out_stream.puts opts.help
|
131
|
-
Kernel.exit
|
132
|
-
end
|
133
|
-
end.parse!
|
134
|
-
|
135
|
-
if @options[:formats].empty?
|
136
|
-
@options[:formats][DEFAULT_FORMAT] = [@out_stream]
|
137
|
-
end
|
138
|
-
|
139
|
-
# Whatever is left after option parsing is the FILE arguments
|
140
|
-
args = extract_and_store_line_numbers(args)
|
141
|
-
@paths += args
|
142
|
-
end
|
143
|
-
|
144
|
-
|
145
|
-
def execute!(step_mother, executor, features)
|
146
|
-
Term::ANSIColor.coloring = @options[:color] unless @options[:color].nil?
|
147
|
-
Cucumber.load_language(@options[:lang])
|
148
|
-
require_files
|
149
|
-
enable_diffing
|
150
|
-
executor.formatters = build_formatter_broadcaster(step_mother)
|
151
|
-
load_plain_text_features(features)
|
152
|
-
executor.lines_for_features = @options[:lines_for_features]
|
153
|
-
executor.dry_run = @options[:dry_run] if @options[:dry_run]
|
154
|
-
executor.scenario_names = @options[:scenario_names] if @options[:scenario_names]
|
155
|
-
executor.visit_features(features)
|
156
|
-
exit 1 if executor.failed
|
157
|
-
end
|
158
|
-
|
159
|
-
private
|
160
|
-
|
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
|
-
def cucumber_yml
|
174
|
-
return @cucumber_yml if @cucumber_yml
|
175
|
-
unless File.exist?('cucumber.yml')
|
176
|
-
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
|
-
end
|
178
|
-
|
179
|
-
require 'yaml'
|
180
|
-
begin
|
181
|
-
@cucumber_yml = YAML::load(IO.read('cucumber.yml'))
|
182
|
-
rescue Exception => e
|
183
|
-
raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentaion on correct profile usage.\n")
|
184
|
-
end
|
185
|
-
|
186
|
-
if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
|
187
|
-
raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentaion on correct profile usage.\n")
|
188
|
-
end
|
189
|
-
|
190
|
-
return @cucumber_yml
|
191
|
-
end
|
192
|
-
|
193
|
-
def parse_args_from_profile(profile)
|
194
|
-
unless cucumber_yml.has_key?(profile)
|
195
|
-
return(exit_with_error <<-END_OF_ERROR)
|
196
|
-
Could not find profile: '#{profile}'
|
197
|
-
|
198
|
-
Defined profiles in cucumber.yml:
|
199
|
-
* #{cucumber_yml.keys.join("\n * ")}
|
200
|
-
END_OF_ERROR
|
201
|
-
end
|
202
|
-
|
203
|
-
args_from_yml = cucumber_yml[profile] || ''
|
204
|
-
|
205
|
-
if !args_from_yml.is_a?(String)
|
206
|
-
exit_with_error "Profiles must be defined as a String. The '#{profile}' profile was #{args_from_yml.inspect} (#{args_from_yml.class}).\n"
|
207
|
-
elsif args_from_yml =~ /^\s*$/
|
208
|
-
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"
|
209
|
-
else
|
210
|
-
parse_options!(args_from_yml.split(' '))
|
211
|
-
end
|
212
|
-
|
213
|
-
rescue YmlLoadError => e
|
214
|
-
exit_with_error(e.message)
|
215
|
-
end
|
216
|
-
|
217
|
-
|
218
|
-
# Requires files - typically step files and ruby feature files.
|
219
|
-
def require_files
|
220
|
-
require "cucumber/treetop_parser/feature_#{@options[:lang]}"
|
221
|
-
require "cucumber/treetop_parser/feature_parser"
|
222
|
-
|
223
|
-
verbose_log("Ruby files required:")
|
224
|
-
files_to_require.each do |lib|
|
225
|
-
begin
|
226
|
-
require lib
|
227
|
-
verbose_log(" * #{lib}")
|
228
|
-
rescue LoadError => e
|
229
|
-
e.message << "\nFailed to load #{lib}"
|
230
|
-
raise e
|
231
|
-
end
|
232
|
-
end
|
233
|
-
verbose_log("\n")
|
234
|
-
end
|
235
|
-
|
236
|
-
def files_to_require
|
237
|
-
requires = @options[:require] || feature_dirs
|
238
|
-
files = requires.map do |path|
|
239
|
-
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
240
|
-
File.directory?(path) ? Dir["#{path}/**/*.rb"] : path
|
241
|
-
end.flatten.uniq
|
242
|
-
files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }
|
243
|
-
end
|
244
|
-
|
245
|
-
def feature_files
|
246
|
-
potential_feature_files = @paths.map do |path|
|
247
|
-
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
248
|
-
path = path.chomp('/')
|
249
|
-
File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
|
250
|
-
end.flatten.uniq
|
251
|
-
|
252
|
-
@options[:excludes].each do |exclude|
|
253
|
-
potential_feature_files.reject! do |path|
|
254
|
-
path =~ /#{Regexp.escape(exclude)}/
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
potential_feature_files
|
259
|
-
end
|
260
|
-
|
261
|
-
def feature_dirs
|
262
|
-
feature_files.map{|f| File.directory?(f) ? f : File.dirname(f)}.uniq
|
263
|
-
end
|
264
|
-
|
265
|
-
def load_plain_text_features(features)
|
266
|
-
parser = TreetopParser::FeatureParser.new
|
267
|
-
|
268
|
-
verbose_log("Features:")
|
269
|
-
feature_files.each do |f|
|
270
|
-
features << parser.parse_feature(f)
|
271
|
-
verbose_log(" * #{f}")
|
272
|
-
end
|
273
|
-
verbose_log("\n"*2)
|
274
|
-
end
|
275
|
-
|
276
|
-
def build_formatter_broadcaster(step_mother)
|
277
|
-
formatter_broadcaster = Broadcaster.new
|
278
|
-
@options[:formats].each do |format, output_list|
|
279
|
-
output_broadcaster = build_output_broadcaster(output_list)
|
280
|
-
case format
|
281
|
-
when 'pretty'
|
282
|
-
formatter_broadcaster.register(Formatters::PrettyFormatter.new(output_broadcaster, step_mother, @options))
|
283
|
-
when 'progress'
|
284
|
-
formatter_broadcaster.register(Formatters::ProgressFormatter.new(output_broadcaster))
|
285
|
-
when 'profile'
|
286
|
-
formatter_broadcaster.register(Formatters::ProfileFormatter.new(output_broadcaster, step_mother))
|
287
|
-
when 'html'
|
288
|
-
formatter_broadcaster.register(Formatters::HtmlFormatter.new(output_broadcaster, step_mother))
|
289
|
-
when 'autotest'
|
290
|
-
formatter_broadcaster.register(Formatters::AutotestFormatter.new(output_broadcaster))
|
291
|
-
else
|
292
|
-
begin
|
293
|
-
formatter_class = constantize(format)
|
294
|
-
formatter_broadcaster.register(formatter_class.new(output_broadcaster, step_mother, @options))
|
295
|
-
rescue NameError => e
|
296
|
-
@error_stream.puts "Invalid format: #{format}\n"
|
297
|
-
exit_with_help
|
298
|
-
rescue Exception => e
|
299
|
-
exit_with_error("Error creating formatter: #{format}\n#{e}\n")
|
300
|
-
end
|
301
|
-
end
|
302
|
-
end
|
303
|
-
formatter_broadcaster
|
304
|
-
end
|
305
|
-
|
306
|
-
def build_output_broadcaster(output_list)
|
307
|
-
output_broadcaster = Broadcaster.new
|
308
|
-
output_list.each do |output|
|
309
|
-
output_broadcaster.register(output)
|
310
|
-
end
|
311
|
-
output_broadcaster
|
312
|
-
end
|
313
|
-
|
314
|
-
private
|
315
|
-
|
316
|
-
def constantize(camel_cased_word)
|
317
|
-
names = camel_cased_word.split('::')
|
318
|
-
names.shift if names.empty? || names.first.empty?
|
319
|
-
|
320
|
-
constant = Object
|
321
|
-
names.each do |name|
|
322
|
-
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
323
|
-
end
|
324
|
-
constant
|
325
|
-
end
|
326
|
-
|
327
|
-
def verbose_log(string)
|
328
|
-
@out_stream.puts(string) if @options[:verbose]
|
329
|
-
end
|
330
|
-
|
331
|
-
def exit_with_help
|
332
|
-
parse_options!(%w{--help})
|
333
|
-
end
|
334
|
-
|
335
|
-
def exit_with_error(error_message)
|
336
|
-
@error_stream << error_message
|
337
|
-
Kernel.exit 1
|
338
|
-
end
|
339
|
-
|
340
|
-
def enable_diffing
|
341
|
-
if defined?(::Spec)
|
342
|
-
require 'spec/expectations/differs/default'
|
343
|
-
options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
|
344
|
-
::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
|
345
|
-
end
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
extend Cucumber::StepMethods
|
351
|
-
Cucumber::CLI.step_mother = step_mother
|
352
|
-
Cucumber::CLI.executor = executor
|
353
|
-
|
354
|
-
extend Cucumber::Tree
|
355
|
-
Cucumber::CLI.features = features
|