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
data/lib/cucumber/ast.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'cucumber/ast/comment'
|
2
|
+
require 'cucumber/ast/tags'
|
3
|
+
require 'cucumber/ast/features'
|
4
|
+
require 'cucumber/ast/feature'
|
5
|
+
require 'cucumber/ast/scenario'
|
6
|
+
require 'cucumber/ast/scenario_outline'
|
7
|
+
require 'cucumber/ast/background'
|
8
|
+
require 'cucumber/ast/steps'
|
9
|
+
require 'cucumber/ast/step'
|
10
|
+
require 'cucumber/ast/table'
|
11
|
+
require 'cucumber/ast/py_string'
|
12
|
+
require 'cucumber/ast/outline_table'
|
13
|
+
require 'cucumber/ast/examples'
|
14
|
+
require 'cucumber/ast/visitor'
|
15
|
+
require 'cucumber/ast/filter'
|
16
|
+
|
17
|
+
module Cucumber
|
18
|
+
# Classes in this module represent the Abstract Syntax Tree (AST)
|
19
|
+
# that gets built when feature files are parsed.
|
20
|
+
#
|
21
|
+
# AST classes don't expose any internal data directly. This is
|
22
|
+
# in order to encourage a less coupled design in the classes
|
23
|
+
# that operate on the AST. The only public method is #accept.
|
24
|
+
#
|
25
|
+
# The AST can be traversed with a visitor. See Cucumber::Format::Pretty
|
26
|
+
# for an example.
|
27
|
+
module Ast
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Ast
|
3
|
+
class Background < Scenario
|
4
|
+
|
5
|
+
attr_accessor :world
|
6
|
+
attr_reader :status
|
7
|
+
|
8
|
+
def initialize(comment, line, keyword, steps)
|
9
|
+
@record_executed_steps = true
|
10
|
+
super(comment, Tags.new(1, []), line, keyword, "", steps)
|
11
|
+
end
|
12
|
+
|
13
|
+
def accept(visitor)
|
14
|
+
@world = visitor.new_world
|
15
|
+
if already_visited_steps?
|
16
|
+
@status = execute_steps(visitor)
|
17
|
+
else
|
18
|
+
@status = visit_background_and_steps(visitor, @steps)
|
19
|
+
@steps_visited = true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def step_executed(step)
|
24
|
+
@feature.step_executed(step) if @feature && @record_executed_steps
|
25
|
+
end
|
26
|
+
|
27
|
+
def already_visited_steps?
|
28
|
+
@steps_visited
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_sexp #:nodoc:
|
32
|
+
sexp = [:background, @line, @keyword]
|
33
|
+
comment = @comment.to_sexp
|
34
|
+
sexp += [comment] if comment
|
35
|
+
tags = @tags.to_sexp
|
36
|
+
sexp += tags if tags.any?
|
37
|
+
steps = @steps.map{|step| step.to_sexp}
|
38
|
+
sexp += steps if steps.any?
|
39
|
+
sexp
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def visit_background_and_steps(visitor, steps)
|
45
|
+
visitor.visit_comment(@comment)
|
46
|
+
visitor.visit_scenario_name(@keyword, @name, file_line(@line), source_indent(text_length))
|
47
|
+
|
48
|
+
previous = :passed
|
49
|
+
steps.each do |step|
|
50
|
+
step.previous = previous
|
51
|
+
step.world = @world
|
52
|
+
visitor.visit_step(step)
|
53
|
+
previous = step.status
|
54
|
+
end
|
55
|
+
previous
|
56
|
+
end
|
57
|
+
|
58
|
+
def execute_steps(visitor)
|
59
|
+
previous = :passed
|
60
|
+
executed_steps = []
|
61
|
+
exception = nil
|
62
|
+
@steps.each do |step|
|
63
|
+
executed_step, previous, _ = step.execute_as_new(@world, previous, visitor, @line)
|
64
|
+
executed_steps << executed_step
|
65
|
+
exception ||= executed_step.exception
|
66
|
+
end
|
67
|
+
@steps = executed_steps
|
68
|
+
|
69
|
+
if exception && @status != :failed
|
70
|
+
without_recording_steps do
|
71
|
+
@steps_visited = false
|
72
|
+
#Since the steps have already been executed they will not be re-run, they will just be displayed
|
73
|
+
visitor.visit_background(self)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
previous
|
78
|
+
end
|
79
|
+
|
80
|
+
def without_recording_steps
|
81
|
+
@record_executed_steps = false
|
82
|
+
yield
|
83
|
+
@record_executed_steps = true
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Ast
|
3
|
+
# Holds the value of a comment parsed from a feature file:
|
4
|
+
#
|
5
|
+
# # Lorem ipsum
|
6
|
+
# # dolor sit amet
|
7
|
+
#
|
8
|
+
# This gets parsed into a Comment with value <tt>"# Lorem ipsum\n# dolor sit amet\n"</tt>
|
9
|
+
#
|
10
|
+
class Comment
|
11
|
+
def initialize(value)
|
12
|
+
@value = value
|
13
|
+
end
|
14
|
+
|
15
|
+
def accept(visitor)
|
16
|
+
@value.split("\n").each do |line|
|
17
|
+
visitor.visit_comment_line(line.strip)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_sexp
|
22
|
+
(@value.nil? || @value == '') ? nil : [:comment, @value]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Ast
|
3
|
+
class Examples
|
4
|
+
def initialize(line, keyword, name, outline_table)
|
5
|
+
@keyword, @name, @outline_table = keyword, name, outline_table
|
6
|
+
end
|
7
|
+
|
8
|
+
def accept(visitor)
|
9
|
+
visitor.visit_examples_name(@keyword, @name)
|
10
|
+
visitor.visit_outline_table(@outline_table)
|
11
|
+
end
|
12
|
+
|
13
|
+
def each_example_row(&proc)
|
14
|
+
@outline_table.each_cells_row(&proc)
|
15
|
+
end
|
16
|
+
|
17
|
+
def at_lines?(lines)
|
18
|
+
lines.empty? || lines.index(@line) || @outline_table.at_lines?(lines)
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_sexp
|
22
|
+
[:examples, @keyword, @name, @outline_table.to_sexp]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Ast
|
3
|
+
# Represents the root node of a parsed feature.
|
4
|
+
class Feature
|
5
|
+
attr_accessor :file
|
6
|
+
attr_writer :features, :lines
|
7
|
+
|
8
|
+
def initialize(comment, tags, name, feature_elements, background = nil)
|
9
|
+
@comment, @tags, @name, @feature_elements, @background = comment, tags, name, feature_elements, background
|
10
|
+
feature_elements.each do |feature_element|
|
11
|
+
feature_element.feature = self
|
12
|
+
feature_element.background = background if background
|
13
|
+
end
|
14
|
+
background.feature = self if background
|
15
|
+
@lines = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def tagged_with?(tag_names, check_elements=true)
|
19
|
+
@tags.among?(tag_names) ||
|
20
|
+
(check_elements && @feature_elements.detect{|e| e.tagged_with?(tag_names)})
|
21
|
+
end
|
22
|
+
|
23
|
+
def matches_scenario_names?(scenario_names)
|
24
|
+
@feature_elements.detect{|e| e.matches_scenario_names?(scenario_names)}
|
25
|
+
end
|
26
|
+
|
27
|
+
def accept(visitor)
|
28
|
+
visitor.current_feature_lines = @lines
|
29
|
+
visitor.visit_comment(@comment)
|
30
|
+
visitor.visit_tags(@tags)
|
31
|
+
visitor.visit_feature_name(@name)
|
32
|
+
|
33
|
+
@feature_elements.each do |feature_element|
|
34
|
+
visitor.visit_feature_element(feature_element) if @features.visit?(feature_element, @lines)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def scenario_executed(scenario)
|
39
|
+
@features.scenario_executed(scenario) if @features
|
40
|
+
end
|
41
|
+
|
42
|
+
def step_executed(step)
|
43
|
+
@features.step_executed(step) if @features
|
44
|
+
end
|
45
|
+
|
46
|
+
def backtrace_line(step_name, line)
|
47
|
+
"#{file_line(line)}:in `#{step_name}'"
|
48
|
+
end
|
49
|
+
|
50
|
+
def file_line(line)
|
51
|
+
"#{@file}:#{line}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_sexp
|
55
|
+
sexp = [:feature, @name]
|
56
|
+
comment = @comment.to_sexp
|
57
|
+
sexp += [comment] if comment
|
58
|
+
tags = @tags.to_sexp
|
59
|
+
sexp += tags if tags.any?
|
60
|
+
sexp += [@background.to_sexp] if @background
|
61
|
+
sexp += @feature_elements.map{|e| e.to_sexp}
|
62
|
+
sexp
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Ast
|
3
|
+
class Features
|
4
|
+
attr_reader :steps, :scenarios
|
5
|
+
|
6
|
+
def initialize(filter)
|
7
|
+
@filter = filter
|
8
|
+
|
9
|
+
@features = []
|
10
|
+
@scenarios = []
|
11
|
+
@steps = Hash.new{|steps, status| steps[status] = []}
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_feature(feature)
|
15
|
+
feature.features = self
|
16
|
+
@features << feature
|
17
|
+
end
|
18
|
+
|
19
|
+
def visit?(node, lines)
|
20
|
+
@filter.matched?(node) &&
|
21
|
+
(lines.empty? ? true : node.at_lines?(lines))
|
22
|
+
end
|
23
|
+
|
24
|
+
def scenario_executed(scenario)
|
25
|
+
@scenarios << scenario
|
26
|
+
end
|
27
|
+
|
28
|
+
def step_executed(step)
|
29
|
+
@steps[step.status] << step
|
30
|
+
end
|
31
|
+
|
32
|
+
def accept(visitor)
|
33
|
+
@features.each do |feature|
|
34
|
+
visitor.visit_feature(feature) if visit?(feature, [])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Ast
|
3
|
+
class Filter
|
4
|
+
def initialize(options)
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
def matched?(node)
|
9
|
+
matched_by_tags?(node) &&
|
10
|
+
matched_by_scenario_names?(node)
|
11
|
+
end
|
12
|
+
|
13
|
+
def matched_by_tags?(node)
|
14
|
+
@options[:tags].empty? || node.tagged_with?(@options[:tags])
|
15
|
+
end
|
16
|
+
|
17
|
+
def matched_by_scenario_names?(node)
|
18
|
+
@options[:scenario_names].empty? || node.matches_scenario_names?(@options[:scenario_names])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Ast
|
3
|
+
class OutlineTable < Table
|
4
|
+
def initialize(raw, scenario_outline)
|
5
|
+
super(raw)
|
6
|
+
@scenario_outline = scenario_outline
|
7
|
+
@cells_class = ExampleCells
|
8
|
+
end
|
9
|
+
|
10
|
+
def accept(visitor, status)
|
11
|
+
cells_rows.each_with_index do |row, n|
|
12
|
+
should_visit = n == 0 ||
|
13
|
+
row.at_lines?(visitor.current_feature_lines) ||
|
14
|
+
@scenario_outline.at_header_or_step_lines?(visitor.current_feature_lines)
|
15
|
+
|
16
|
+
if should_visit
|
17
|
+
visitor.visit_table_row(row, status)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute_row(cells, visitor, &proc)
|
24
|
+
@scenario_outline.execute_row(cells, visitor, &proc)
|
25
|
+
end
|
26
|
+
|
27
|
+
class ExampleCells < Cells
|
28
|
+
def accept(visitor, status)
|
29
|
+
if header?
|
30
|
+
@cells.each do |cell|
|
31
|
+
visitor.visit_table_cell(cell, :thead)
|
32
|
+
end
|
33
|
+
nil
|
34
|
+
else
|
35
|
+
exception = @table.execute_row(self, visitor) do |cell, status|
|
36
|
+
visitor.visit_table_cell(cell, status)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def header?
|
44
|
+
index == 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Ast
|
3
|
+
# Represents an inline argument in a step. Example:
|
4
|
+
#
|
5
|
+
# Given the message
|
6
|
+
# """
|
7
|
+
# I like
|
8
|
+
# Cucumber sandwich
|
9
|
+
# """
|
10
|
+
#
|
11
|
+
# The text between the pair of <tt>"""</tt> is stored inside a PyString,
|
12
|
+
# which is yielded to the StepDefinition block as the last argument.
|
13
|
+
#
|
14
|
+
# The StepDefinition can then access the String via the #to_s method. In the
|
15
|
+
# example above, that would return: <tt>"I like\nCucumber sandwich"</tt>
|
16
|
+
#
|
17
|
+
# Note how the indentation from the source is stripped away.
|
18
|
+
#
|
19
|
+
class PyString
|
20
|
+
def initialize(start_line, end_line, string, quotes_indent)
|
21
|
+
@start_line, @end_line = start_line, end_line
|
22
|
+
@string, @quotes_indent = string.gsub(/\\"/, '"'), quotes_indent
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
@string.indent(-@quotes_indent)
|
27
|
+
end
|
28
|
+
|
29
|
+
def at_lines?(lines)
|
30
|
+
lines.detect{|l| l >= @start_line && l <= @end_line}
|
31
|
+
end
|
32
|
+
|
33
|
+
def accept(visitor, status)
|
34
|
+
visitor.visit_py_string(to_s, status)
|
35
|
+
end
|
36
|
+
|
37
|
+
def arguments_replaced(arguments) #:nodoc:
|
38
|
+
string = @string
|
39
|
+
arguments.each do |name, value|
|
40
|
+
string = string.gsub(name, value)
|
41
|
+
end
|
42
|
+
PyString.new(@start_line, @end_line, string, @quotes_indent)
|
43
|
+
end
|
44
|
+
|
45
|
+
# For testing only
|
46
|
+
def to_sexp #:nodoc:
|
47
|
+
[:py_string, to_s]
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Ast
|
3
|
+
class Scenario
|
4
|
+
attr_writer :feature, :background
|
5
|
+
|
6
|
+
def initialize(comment, tags, line, keyword, name, steps)
|
7
|
+
@comment, @tags, @line, @keyword, @name = comment, tags, line, keyword, name
|
8
|
+
steps.each {|step| step.scenario = self}
|
9
|
+
@steps = steps
|
10
|
+
@steps_helper = Steps.new(self)
|
11
|
+
end
|
12
|
+
|
13
|
+
def status
|
14
|
+
@steps.map{|step| step.status}
|
15
|
+
end
|
16
|
+
|
17
|
+
def tagged_with?(tag_names)
|
18
|
+
@tags.among?(tag_names) || @feature.tagged_with?(tag_names, false)
|
19
|
+
end
|
20
|
+
|
21
|
+
def matches_scenario_names?(scenario_names)
|
22
|
+
scenario_names.detect{|name| @name == name}
|
23
|
+
end
|
24
|
+
|
25
|
+
def accept(visitor)
|
26
|
+
visitor.visit_background(@background) if @background
|
27
|
+
visitor.visit_comment(@comment)
|
28
|
+
visitor.visit_tags(@tags)
|
29
|
+
visitor.visit_scenario_name(@keyword, @name, file_line(@line), source_indent(text_length))
|
30
|
+
visitor.visit_steps(@steps_helper)
|
31
|
+
|
32
|
+
@feature.scenario_executed(self) if @feature && !@executed
|
33
|
+
@executed = true
|
34
|
+
end
|
35
|
+
|
36
|
+
def accept_steps(visitor)
|
37
|
+
prior_world = @background ? @background.world : nil
|
38
|
+
visitor.world(self, prior_world) do |world|
|
39
|
+
previous = @background ? @background.status : :passed
|
40
|
+
@steps.each do |step|
|
41
|
+
step.previous = previous
|
42
|
+
step.world = world
|
43
|
+
visitor.visit_step(step)
|
44
|
+
previous = step.status
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def source_indent(text_length)
|
50
|
+
max_line_length - text_length
|
51
|
+
end
|
52
|
+
|
53
|
+
def max_line_length
|
54
|
+
lengths = (@steps + [self]).map{|e| e.text_length}
|
55
|
+
lengths.max
|
56
|
+
end
|
57
|
+
|
58
|
+
def text_length
|
59
|
+
@keyword.jlength + @name.jlength
|
60
|
+
end
|
61
|
+
|
62
|
+
def at_lines?(lines)
|
63
|
+
at_header_or_step_lines?(lines)
|
64
|
+
end
|
65
|
+
|
66
|
+
def at_header_or_step_lines?(lines)
|
67
|
+
lines.empty? || lines.index(@line) || @steps.detect {|step| step.at_lines?(lines)} || @tags.at_lines?(lines)
|
68
|
+
end
|
69
|
+
|
70
|
+
def undefined?
|
71
|
+
@steps.empty?
|
72
|
+
end
|
73
|
+
|
74
|
+
def step_executed(step)
|
75
|
+
@feature.step_executed(step) if @feature
|
76
|
+
end
|
77
|
+
|
78
|
+
def backtrace_line(name = "#{@keyword} #{@name}", line = @line)
|
79
|
+
@feature.backtrace_line(name, line) if @feature
|
80
|
+
end
|
81
|
+
|
82
|
+
def file_line(line = @line)
|
83
|
+
@feature.file_line(line) if @feature
|
84
|
+
end
|
85
|
+
|
86
|
+
def previous_step(step)
|
87
|
+
i = @steps.index(step) || -1
|
88
|
+
@steps[i-1]
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_sexp
|
92
|
+
sexp = [:scenario, @line, @keyword, @name]
|
93
|
+
comment = @comment.to_sexp
|
94
|
+
sexp += [comment] if comment
|
95
|
+
tags = @tags.to_sexp
|
96
|
+
sexp += tags if tags.any?
|
97
|
+
steps = @steps.map{|step| step.to_sexp}
|
98
|
+
sexp += steps if steps.any?
|
99
|
+
sexp
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|