kosmas58-cucumber 0.1.99.22 → 0.1.99.23
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +525 -0
- data/License.txt +20 -0
- data/Manifest.txt +322 -0
- data/README.txt +25 -0
- data/Rakefile +8 -0
- data/bin/cucumber +6 -0
- data/config/hoe.rb +76 -0
- data/config/requirements.rb +15 -0
- data/cucumber.yml +1 -0
- data/examples/cs/README.textile +1 -0
- data/examples/cs/Rakefile +12 -0
- data/examples/cs/compile.bat +1 -0
- data/examples/cs/features/addition.feature +16 -0
- data/examples/cs/features/step_definitons/calculator_steps.rb +19 -0
- data/examples/cs/src/demo/Calculator.cs +20 -0
- data/examples/dos_line_endings/Rakefile +6 -0
- data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
- data/examples/i18n/README.textile +18 -0
- data/examples/i18n/Rakefile +32 -0
- data/examples/i18n/ar/Rakefile +6 -0
- data/examples/i18n/ar/features/addition.feature +16 -0
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/ar/lib/calculator.rb +10 -0
- data/examples/i18n/da/Rakefile +6 -0
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +24 -0
- data/examples/i18n/da/features/summering.feature +17 -0
- data/examples/i18n/da/lib/kalkulator.rb +11 -0
- data/examples/i18n/de/Rakefile +6 -0
- data/examples/i18n/de/features/addition.feature +16 -0
- data/examples/i18n/de/features/division.feature +9 -0
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/de/lib/calculator.rb +14 -0
- data/examples/i18n/en/Rakefile +6 -0
- data/examples/i18n/en/features/addition.feature +16 -0
- data/examples/i18n/en/features/division.feature +9 -0
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/en/lib/calculator.rb +14 -0
- data/examples/i18n/es/Rakefile +6 -0
- data/examples/i18n/es/features/adicion.feature +16 -0
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +21 -0
- data/examples/i18n/es/lib/calculador.rb +14 -0
- data/examples/i18n/et/Rakefile +6 -0
- data/examples/i18n/et/features/liitmine.feature +16 -0
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +24 -0
- data/examples/i18n/et/lib/kalkulaator.rb +14 -0
- data/examples/i18n/fi/Rakefile +6 -0
- data/examples/i18n/fi/features/jakolasku.feature +9 -0
- data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +24 -0
- data/examples/i18n/fi/features/yhteenlasku.feature +16 -0
- data/examples/i18n/fi/lib/laskin.rb +14 -0
- data/examples/i18n/fr/Rakefile +6 -0
- data/examples/i18n/fr/features/addition.feature +17 -0
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +25 -0
- data/examples/i18n/fr/lib/calculatrice.rb +10 -0
- data/examples/i18n/id/Rakefile +6 -0
- data/examples/i18n/id/features/addition.feature +16 -0
- data/examples/i18n/id/features/division.feature +9 -0
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/id/lib/calculator.rb +14 -0
- data/examples/i18n/it/Rakefile +6 -0
- data/examples/i18n/it/features/somma.feature +10 -0
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +24 -0
- data/examples/i18n/it/lib/calcolatrice.rb +11 -0
- data/examples/i18n/ja/Rakefile +6 -0
- data/examples/i18n/ja/features/addition.feature +16 -0
- data/examples/i18n/ja/features/division.feature +9 -0
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/ja/lib/calculator.rb +14 -0
- data/examples/i18n/ko/Rakefile +6 -0
- data/examples/i18n/ko/features/addition.feature +16 -0
- data/examples/i18n/ko/features/division.feature +10 -0
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/ko/lib/calculator.rb +14 -0
- data/examples/i18n/lt/Rakefile +6 -0
- data/examples/i18n/lt/features/addition.feature +17 -0
- data/examples/i18n/lt/features/division.feature +9 -0
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/lt/lib/calculator.rb +14 -0
- data/examples/i18n/no/Rakefile +6 -0
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +17 -0
- data/examples/i18n/no/features/summering.feature +18 -0
- data/examples/i18n/no/features/support/env.rb +6 -0
- data/examples/i18n/no/lib/kalkulator.rb +11 -0
- data/examples/i18n/pt/Rakefile +6 -0
- data/examples/i18n/pt/features/adicao.feature +10 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +24 -0
- data/examples/i18n/pt/lib/calculadora.rb +10 -0
- data/examples/i18n/ro/Rakefile +6 -0
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/ro/features/suma.feature +10 -0
- data/examples/i18n/ro/lib/calculator.rb +11 -0
- data/examples/i18n/ru/Rakefile +6 -0
- data/examples/i18n/ru/features/addition.feature +10 -0
- data/examples/i18n/ru/features/consecutive_calculations.feature +16 -0
- data/examples/i18n/ru/features/division.feature +15 -0
- data/examples/i18n/ru/features/step_definitons/calculator_steps.rb +19 -0
- data/examples/i18n/ru/features/support/env.rb +6 -0
- data/examples/i18n/ru/features/support/world.rb +7 -0
- data/examples/i18n/ru/lib/calculator.rb +24 -0
- data/examples/i18n/se/Rakefile +6 -0
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +24 -0
- data/examples/i18n/se/features/summering.feature +17 -0
- data/examples/i18n/se/lib/kalkulator.rb +11 -0
- data/examples/i18n/zh-CN/Rakefile +6 -0
- data/examples/i18n/zh-CN/features/addition.feature +17 -0
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +26 -0
- data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
- data/examples/i18n/zh-TW/Rakefile +6 -0
- data/examples/i18n/zh-TW/features/addition.feature +16 -0
- data/examples/i18n/zh-TW/features/division.feature +10 -0
- data/examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/zh-TW/lib/calculator.rb +14 -0
- data/examples/java/README.textile +22 -0
- data/examples/java/Rakefile +12 -0
- data/examples/java/features/hello.feature +11 -0
- data/examples/java/features/step_definitons/hello_steps.rb +25 -0
- data/examples/java/features/step_definitons/tree_steps.rb +14 -0
- data/examples/java/features/tree.feature +9 -0
- 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/selenium/Rakefile +6 -0
- data/examples/selenium/features/search.feature +9 -0
- data/examples/self_test/README.textile +6 -0
- data/examples/self_test/Rakefile +6 -0
- 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/failing_expectation.feature +4 -0
- data/examples/self_test/features/lots_of_undefined.feature +8 -0
- data/examples/self_test/features/outline_sample.feature +15 -0
- data/examples/self_test/features/sample.feature +19 -0
- data/examples/self_test/features/step_definitions/sample_steps.rb +64 -0
- data/examples/self_test/features/support/env.rb +1 -0
- data/examples/self_test/features/support/tag_count_formatter.rb +25 -0
- data/examples/sinatra/Rakefile +6 -0
- data/examples/sinatra/app.rb +14 -0
- data/examples/sinatra/features/add.feature +11 -0
- data/examples/sinatra/features/step_definitions/add_steps.rb +15 -0
- data/examples/sinatra/features/support/env.rb +20 -0
- data/examples/sinatra/views/add.erb +5 -0
- data/examples/sinatra/views/layout.erb +8 -0
- data/examples/test_unit/Rakefile +6 -0
- data/examples/test_unit/features/step_definitions/test_unit_steps.rb +26 -0
- data/examples/test_unit/features/test_unit.feature +9 -0
- data/examples/tickets/Rakefile +11 -0
- data/examples/tickets/cucumber.yml +2 -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/lib/eatting_machine.rb +18 -0
- data/examples/tickets/features/lib/pantry.rb +20 -0
- data/examples/tickets/features/scenario_outline.feature +95 -0
- data/examples/tickets/features/step_definitons/scenario_outline_steps.rb +42 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +60 -0
- data/examples/tickets/features/tickets.feature +28 -0
- data/examples/watir/README.textile +16 -0
- data/examples/watir/Rakefile +6 -0
- data/examples/watir/features/search.feature +9 -0
- data/examples/watir/features/step_definitons/search_steps.rb +24 -0
- data/examples/watir/features/support/env.rb +32 -0
- data/features/background.feature +223 -0
- data/features/cucumber_cli.feature +366 -0
- data/features/cucumber_cli_diff_disabled.feature +45 -0
- data/features/cucumber_cli_outlines.feature +90 -0
- data/features/custom_formatter.feature +11 -0
- data/features/report_called_undefined_steps.feature +32 -0
- data/features/step_definitions/cucumber_steps.rb +30 -0
- data/features/step_definitions/extra_steps.rb +2 -0
- data/features/support/env.rb +8 -0
- data/gem_tasks/deployment.rake +11 -0
- data/gem_tasks/environment.rake +7 -0
- data/gem_tasks/features.rake +9 -0
- data/gem_tasks/fix_cr_lf.rake +10 -0
- data/gem_tasks/flog.rake +4 -0
- data/gem_tasks/gemspec.rake +10 -0
- data/gem_tasks/jar.rake +67 -0
- data/gem_tasks/rspec.rake +38 -0
- data/gem_tasks/yard.rake +8 -0
- data/lib/autotest/cucumber.rb +6 -0
- data/lib/autotest/cucumber_mixin.rb +125 -0
- data/lib/autotest/cucumber_rails.rb +6 -0
- data/lib/autotest/cucumber_rails_rspec.rb +6 -0
- data/lib/autotest/cucumber_rspec.rb +6 -0
- data/lib/autotest/discover.rb +9 -0
- data/lib/cucumber.rb +71 -0
- 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 +290 -0
- data/lib/cucumber/ast/tags.rb +40 -0
- data/lib/cucumber/ast/visitor.rb +109 -0
- data/lib/cucumber/broadcaster.rb +15 -0
- data/lib/cucumber/cli/configuration.rb +356 -0
- data/lib/cucumber/cli/language_help_formatter.rb +59 -0
- data/lib/cucumber/cli/main.rb +107 -0
- data/lib/cucumber/core_ext/exception.rb +53 -0
- data/lib/cucumber/core_ext/instance_exec.rb +54 -0
- data/lib/cucumber/core_ext/proc.rb +33 -0
- data/lib/cucumber/core_ext/string.rb +48 -0
- data/lib/cucumber/formatter.rb +1 -0
- data/lib/cucumber/formatter/ansicolor.rb +103 -0
- data/lib/cucumber/formatter/color_io.rb +23 -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 +126 -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 -0
- data/lib/cucumber/jbehave.rb +102 -0
- data/lib/cucumber/languages.yml +374 -0
- 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 +18 -0
- data/lib/cucumber/rails/rspec.rb +8 -0
- data/lib/cucumber/rails/world.rb +73 -0
- data/lib/cucumber/rake/task.rb +146 -0
- data/lib/cucumber/step_definition.rb +94 -0
- data/lib/cucumber/step_mother.rb +194 -0
- data/lib/cucumber/version.rb +10 -0
- data/rails_generators/cucumber/USAGE +14 -0
- data/rails_generators/cucumber/cucumber_generator.rb +75 -0
- data/rails_generators/cucumber/templates/cucumber +8 -0
- data/rails_generators/cucumber/templates/cucumber.rake +20 -0
- data/rails_generators/cucumber/templates/env.rb +17 -0
- data/rails_generators/cucumber/templates/paths.rb +19 -0
- data/rails_generators/cucumber/templates/webrat_steps.rb +115 -0
- data/rails_generators/feature/USAGE +15 -0
- data/rails_generators/feature/feature_generator.rb +60 -0
- data/rails_generators/feature/templates/feature.erb +31 -0
- data/rails_generators/feature/templates/steps.erb +24 -0
- 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 +139 -0
- data/spec/cucumber/ast/tags_spec.rb +35 -0
- data/spec/cucumber/broadcaster_spec.rb +14 -0
- data/spec/cucumber/cli/configuration_spec.rb +268 -0
- data/spec/cucumber/cli/main_spec.rb +204 -0
- data/spec/cucumber/core_ext/proc_spec.rb +37 -0
- data/spec/cucumber/core_ext/string_spec.rb +42 -0
- data/spec/cucumber/formatter/ansicolor_spec.rb +35 -0
- data/spec/cucumber/formatter/color_io_spec.rb +26 -0
- 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 +198 -0
- data/spec/cucumber/parser/feature_parser_spec.rb +281 -0
- data/spec/cucumber/parser/table_parser_spec.rb +48 -0
- data/spec/cucumber/rails/stubs/mini_rails.rb +18 -0
- data/spec/cucumber/rails/stubs/test_help.rb +1 -0
- data/spec/cucumber/rails/world_spec.rb +11 -0
- data/spec/cucumber/sell_cucumbers.feature +19 -0
- data/spec/cucumber/step_definition_spec.rb +70 -0
- data/spec/cucumber/step_mother_spec.rb +73 -0
- data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
- data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
- data/spec/cucumber/treetop_parser/empty_scenario_outline.feature +3 -0
- data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
- data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
- data/spec/cucumber/treetop_parser/invalid_scenario_outlines.feature +7 -0
- data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
- data/spec/cucumber/treetop_parser/multiple_tables.feature +27 -0
- data/spec/cucumber/treetop_parser/scenario_outline.feature +16 -0
- data/spec/cucumber/treetop_parser/spaces.feature +12 -0
- data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
- data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
- data/spec/cucumber/treetop_parser/with_tags.feature +18 -0
- data/spec/cucumber/world/pending_spec.rb +47 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +21 -0
- metadata +329 -9
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'cucumber/formatter/pretty'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Cli
|
5
|
+
class LanguageHelpFormatter < Formatter::Pretty
|
6
|
+
INCOMPLETE = %{
|
7
|
+
The Cucumber grammar has evolved since this translation was written.
|
8
|
+
Please help us complete the translation by translating the missing words in
|
9
|
+
|
10
|
+
#{Cucumber::LANGUAGE_FILE}
|
11
|
+
|
12
|
+
Then contribute back to the Cucumber project. Details here:
|
13
|
+
http://wiki.github.com/aslakhellesoy/cucumber/spoken-languages
|
14
|
+
}
|
15
|
+
|
16
|
+
def self.list_languages(io)
|
17
|
+
raw = Cucumber::LANGUAGES.keys.sort.map do |lang|
|
18
|
+
[lang, Cucumber::LANGUAGES[lang]['name'], Cucumber::LANGUAGES[lang]['native']]
|
19
|
+
end
|
20
|
+
table = Ast::Table.new(raw)
|
21
|
+
new(nil, io, {:check_lang=>true}, '').visit_multiline_arg(table, :passed)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.list_keywords(io, lang)
|
25
|
+
raw = Cucumber::KEYWORD_KEYS.map do |key|
|
26
|
+
[key, Cucumber::LANGUAGES[lang][key]]
|
27
|
+
end
|
28
|
+
table = Ast::Table.new(raw)
|
29
|
+
new(nil, io, {:incomplete => Cucumber.language_incomplete?(lang)}, '').visit_multiline_arg(table, :passed)
|
30
|
+
end
|
31
|
+
|
32
|
+
def visit_multiline_arg(table, status)
|
33
|
+
if @options[:incomplete]
|
34
|
+
@io.puts(format_string(INCOMPLETE, :failed))
|
35
|
+
end
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
def visit_table_row(table_row, status)
|
40
|
+
@col = 1
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
def visit_table_cell_value(value, width, status)
|
45
|
+
if @col == 1
|
46
|
+
if(@options[:check_lang])
|
47
|
+
@incomplete = Cucumber.language_incomplete?(value)
|
48
|
+
end
|
49
|
+
status = :comment
|
50
|
+
elsif @incomplete
|
51
|
+
status = :undefined
|
52
|
+
end
|
53
|
+
|
54
|
+
@col += 1
|
55
|
+
super(value, width, status)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'cucumber'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'cucumber/parser'
|
5
|
+
require 'cucumber/formatter'
|
6
|
+
require 'cucumber/cli/language_help_formatter'
|
7
|
+
require 'cucumber/cli/configuration'
|
8
|
+
|
9
|
+
module Cucumber
|
10
|
+
module Cli
|
11
|
+
class Main
|
12
|
+
class << self
|
13
|
+
def step_mother=(step_mother)
|
14
|
+
@step_mother = step_mother
|
15
|
+
@step_mother.extend(StepMother)
|
16
|
+
@step_mother.snippet_generator = StepDefinition
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute(args)
|
20
|
+
new(args).execute!(@step_mother)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(args, out_stream = STDOUT, error_stream = STDERR)
|
25
|
+
@args = args
|
26
|
+
@out_stream = out_stream == STDOUT ? Formatter::ColorIO.new : out_stream
|
27
|
+
@error_stream = error_stream
|
28
|
+
end
|
29
|
+
|
30
|
+
def execute!(step_mother)
|
31
|
+
configuration.load_language
|
32
|
+
step_mother.options = configuration.options
|
33
|
+
|
34
|
+
require_files
|
35
|
+
|
36
|
+
if(configuration.print_step_definitions?)
|
37
|
+
step_mother.print_step_definitions(@out_stream)
|
38
|
+
Kernel.exit(0)
|
39
|
+
return # In specs, exit is stubbed
|
40
|
+
end
|
41
|
+
|
42
|
+
enable_diffing
|
43
|
+
|
44
|
+
features = load_plain_text_features
|
45
|
+
|
46
|
+
visitor = configuration.build_formatter_broadcaster(step_mother)
|
47
|
+
visitor.visit_features(features)
|
48
|
+
|
49
|
+
failure = features.steps[:failed].any? || (configuration.strict? && features.steps[:undefined].any?)
|
50
|
+
Kernel.exit(failure ? 1 : 0)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def configuration
|
56
|
+
return @configuration if @configuration
|
57
|
+
|
58
|
+
@configuration = Configuration.new(@out_stream, @error_stream)
|
59
|
+
@configuration.parse!(@args)
|
60
|
+
@configuration
|
61
|
+
end
|
62
|
+
|
63
|
+
def require_files
|
64
|
+
verbose_log("Ruby files required:")
|
65
|
+
configuration.files_to_require.each do |lib|
|
66
|
+
begin
|
67
|
+
require lib
|
68
|
+
verbose_log(" * #{lib}")
|
69
|
+
rescue LoadError => e
|
70
|
+
e.message << "\nFailed to load #{lib}"
|
71
|
+
raise e
|
72
|
+
end
|
73
|
+
end
|
74
|
+
verbose_log("\n")
|
75
|
+
end
|
76
|
+
|
77
|
+
def load_plain_text_features
|
78
|
+
filter = configuration.ast_filter
|
79
|
+
features = Ast::Features.new(filter)
|
80
|
+
parser = Parser::FeatureParser.new
|
81
|
+
|
82
|
+
verbose_log("Features:")
|
83
|
+
configuration.feature_files.each do |f|
|
84
|
+
features.add_feature(parser.parse_file(f))
|
85
|
+
verbose_log(" * #{f}")
|
86
|
+
end
|
87
|
+
verbose_log("\n"*2)
|
88
|
+
features
|
89
|
+
end
|
90
|
+
|
91
|
+
def verbose_log(string)
|
92
|
+
@out_stream.puts(string) if configuration.verbose?
|
93
|
+
end
|
94
|
+
|
95
|
+
def enable_diffing
|
96
|
+
if configuration.diff_enabled? && defined?(::Spec)
|
97
|
+
require 'spec/expectations/differs/default'
|
98
|
+
options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
|
99
|
+
::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
Cucumber::Cli::Main.step_mother = self
|
@@ -0,0 +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
|
+
#
|
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
|
@@ -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
|
@@ -0,0 +1,33 @@
|
|
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
|
@@ -0,0 +1,48 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
%w{color_io pretty progress profile rerun html}.each{|n| require "cucumber/formatter/#{n}"}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
gem 'term-ansicolor'
|
2
|
+
require 'term/ansicolor'
|
3
|
+
|
4
|
+
if Cucumber::WINDOWS_MRI
|
5
|
+
begin
|
6
|
+
gem 'win32console', '>= 1.2.0'
|
7
|
+
require 'Win32/Console/ANSI'
|
8
|
+
rescue LoadError
|
9
|
+
STDERR.puts "*** WARNING: You must gem install win32console (1.2.0 or higher) to get coloured output on MRI/Windows"
|
10
|
+
Term::ANSIColor.coloring = false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Term::ANSIColor.coloring = false if !STDOUT.tty? || (Cucumber::WINDOWS && !Cucumber::WINDOWS_MRI)
|
15
|
+
|
16
|
+
module Cucumber
|
17
|
+
module Formatter
|
18
|
+
# Defines aliases for coloured output. You can tweak the colours by defining
|
19
|
+
# a <tt>CUCUMBER_COLORS</tt> variable in your shell, very much like you can
|
20
|
+
# tweak the familiar POSIX command <tt>ls</tt> with
|
21
|
+
# <a href="http://mipsisrisc.com/rambling/2008/06/27/lscolorsls_colors-now-with-linux-support/">$LSCOLORS/$LS_COLORS</a>
|
22
|
+
#
|
23
|
+
# The colours that you can change are:
|
24
|
+
#
|
25
|
+
# * <tt>undefined</tt> - defaults to <tt>yellow</tt>
|
26
|
+
# * <tt>pending</tt> - defaults to <tt>yellow</tt>
|
27
|
+
# * <tt>pending_param</tt> - defaults to <tt>yellow,bold</tt>
|
28
|
+
# * <tt>failed</tt> - defaults to <tt>red</tt>
|
29
|
+
# * <tt>failed_param</tt> - defaults to <tt>red,bold</tt>
|
30
|
+
# * <tt>passed</tt> - defaults to <tt>green</tt>
|
31
|
+
# * <tt>passed_param</tt> - defaults to <tt>green,bold</tt>
|
32
|
+
# * <tt>outline</tt> - defaults to <tt>cyan</tt>
|
33
|
+
# * <tt>outline_param</tt> - defaults to <tt>cyan,bold</tt>
|
34
|
+
# * <tt>skipped</tt> - defaults to <tt>cyan</tt>
|
35
|
+
# * <tt>skipped_param</tt> - defaults to <tt>cyan,bold</tt>
|
36
|
+
# * <tt>comment</tt> - defaults to <tt>grey</tt>
|
37
|
+
# * <tt>tag</tt> - defaults to <tt>cyan</tt>
|
38
|
+
#
|
39
|
+
# For instance, if your shell has a black background and a green font (like the
|
40
|
+
# "Homebrew" settings for OS X' Terminal.app), you may want to override passed
|
41
|
+
# steps to be white instead of green. Examples:
|
42
|
+
#
|
43
|
+
# export CUCUMBER_COLORS="passed=white"
|
44
|
+
# export CUCUMBER_COLORS="passed=white,bold:passed_param=white,bold,underline"
|
45
|
+
#
|
46
|
+
# (If you're on Windows, use SET instead of export).
|
47
|
+
# To see what colours and effects are available, just run this in your shell:
|
48
|
+
#
|
49
|
+
# ruby -e "require 'rubygems'; require 'term/ansicolor'; puts Term::ANSIColor.attributes"
|
50
|
+
#
|
51
|
+
# Although not listed, you can also use <tt>grey</tt>
|
52
|
+
module ANSIColor
|
53
|
+
include Term::ANSIColor
|
54
|
+
|
55
|
+
# Not supported in Term::ANSIColor
|
56
|
+
def grey(m)
|
57
|
+
if ::Term::ANSIColor.coloring?
|
58
|
+
"\e[90m#{m}\e[0m"
|
59
|
+
else
|
60
|
+
m
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
ALIASES = Hash.new do |h,k|
|
65
|
+
if k.to_s =~ /(.*)_param/
|
66
|
+
h[$1] + ',bold'
|
67
|
+
end
|
68
|
+
end.merge({
|
69
|
+
'undefined' => 'yellow',
|
70
|
+
'pending' => 'yellow',
|
71
|
+
'failed' => 'red',
|
72
|
+
'passed' => 'green',
|
73
|
+
'thead' => 'cyan',
|
74
|
+
'outline' => 'cyan',
|
75
|
+
'skipped' => 'cyan',
|
76
|
+
'comment' => 'grey',
|
77
|
+
'tag' => 'cyan'
|
78
|
+
})
|
79
|
+
|
80
|
+
if ENV['CUCUMBER_COLORS'] # Example: export CUCUMBER_COLORS="passed=red:failed=yellow"
|
81
|
+
ENV['CUCUMBER_COLORS'].split(':').each do |pair|
|
82
|
+
a = pair.split('=')
|
83
|
+
ALIASES[a[0]] = a[1]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
ALIASES.each do |method, color|
|
88
|
+
unless method =~ /.*_param/
|
89
|
+
code = <<-EOF
|
90
|
+
def #{method}(string=nil, &proc)
|
91
|
+
#{ALIASES[method].split(",").join("(") + "(string, &proc" + ")" * ALIASES[method].split(",").length}
|
92
|
+
end
|
93
|
+
# This resets the colour to the non-param colour
|
94
|
+
def #{method}_param(string=nil, &proc)
|
95
|
+
#{ALIASES[method+'_param'].split(",").join("(") + "(string, &proc" + ")" * ALIASES[method+'_param'].split(",").length} + #{ALIASES[method].split(",").join(' + ')}
|
96
|
+
end
|
97
|
+
EOF
|
98
|
+
eval(code)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|