cucumber 0.1.16 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +111 -5
- data/License.txt +1 -1
- data/Manifest.txt +141 -83
- data/Rakefile +1 -1
- data/bin/cucumber +2 -2
- data/config/hoe.rb +8 -2
- data/examples/cs/features/addition.feature +4 -5
- data/examples/cs/features/step_definitons/calculator_steps.rb +1 -5
- data/examples/i18n/README.textile +1 -1
- data/examples/i18n/Rakefile +5 -5
- data/examples/i18n/ar/features/addition.feature +10 -11
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -10
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/de/features/addition.feature +10 -11
- data/examples/i18n/de/features/division.feature +0 -1
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +2 -10
- data/examples/i18n/en-lol/Rakefile +6 -0
- data/examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb +16 -0
- data/examples/i18n/en-lol/features/stuffing.feature +8 -0
- data/examples/i18n/en-lol/features/support/env.rb +8 -0
- data/examples/i18n/en-lol/lib/basket.rb +12 -0
- data/examples/i18n/en-lol/lib/belly.rb +11 -0
- data/examples/i18n/en/features/addition.feature +10 -11
- data/examples/i18n/en/features/division.feature +0 -1
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +2 -6
- 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/jagamine.feature +9 -0
- data/examples/i18n/et/features/liitmine.feature +10 -11
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +4 -8
- data/examples/i18n/et/lib/kalkulaator.rb +5 -1
- 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/features/addition.feature +14 -12
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +11 -13
- data/examples/i18n/fr/lib/calculatrice.rb +1 -1
- data/examples/i18n/id/features/addition.feature +10 -11
- data/examples/i18n/id/features/division.feature +0 -1
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +2 -11
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -1
- data/examples/i18n/ja/features/addition.feature +10 -11
- data/examples/i18n/ja/features/division.feature +2 -3
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +4 -13
- data/examples/i18n/ko/features/addition.feature +7 -8
- data/examples/i18n/ko/features/division.feature +3 -4
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -5
- data/examples/i18n/lt/features/addition.feature +11 -11
- data/examples/i18n/lt/features/division.feature +0 -1
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +2 -11
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +3 -10
- data/examples/i18n/no/features/summering.feature +1 -0
- data/examples/i18n/no/features/support/env.rb +6 -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/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/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +2 -2
- 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/src/cucumber/demo/Hello.java +16 -0
- data/examples/jbehave/README.textile +20 -0
- data/examples/jbehave/features/support/env.rb +7 -0
- data/examples/jbehave/features/trading.feature +28 -0
- data/examples/jbehave/pom.xml +53 -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 +70 -0
- data/examples/selenium/features/step_definitons/search_steps.rb +13 -0
- data/examples/selenium/features/support/env.rb +19 -0
- data/examples/{calculator_ruby_features → selenium_webrat}/Rakefile +0 -0
- data/examples/selenium_webrat/features/search.feature +9 -0
- data/examples/selenium_webrat/features/step_definitons/search_steps.rb +13 -0
- data/examples/selenium_webrat/features/support/env.rb +41 -0
- data/examples/self_test/README.textile +4 -1
- data/examples/self_test/Rakefile +6 -0
- data/examples/self_test/features/background/failing_background.feature +11 -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 +11 -5
- data/examples/self_test/features/sample.feature +8 -3
- data/examples/self_test/features/step_definitions/sample_steps.rb +55 -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/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/tickets/Rakefile +13 -8
- data/examples/tickets/cucumber.yml +2 -1
- 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/236.feature +13 -0
- data/examples/tickets/features/241.feature +13 -0
- data/examples/tickets/features/scenario_outline.feature +6 -1
- data/examples/tickets/features/step_definitons/tickets_steps.rb +41 -4
- data/examples/tickets/features/tickets.feature +5 -1
- data/features/background.feature +221 -0
- data/features/cucumber_cli.feature +263 -97
- data/features/cucumber_cli_diff_disabled.feature +45 -0
- data/features/cucumber_cli_outlines.feature +50 -42
- data/features/custom_formatter.feature +11 -0
- data/features/report_called_undefined_steps.feature +34 -0
- data/features/step_definitions/cucumber_steps.rb +6 -3
- data/features/step_definitions/extra_steps.rb +1 -1
- data/features/support/env.rb +3 -2
- data/gem_tasks/features.rake +1 -1
- data/gem_tasks/flog.rake +1 -1
- data/gem_tasks/gemspec.rake +2 -2
- data/gem_tasks/jar.rake +67 -0
- data/gem_tasks/rspec.rake +2 -0
- data/lib/autotest/cucumber_mixin.rb +18 -23
- data/lib/cucumber.rb +55 -11
- data/lib/cucumber/ast.rb +29 -0
- data/lib/cucumber/ast/background.rb +50 -0
- data/lib/cucumber/ast/comment.rb +26 -0
- data/lib/cucumber/ast/examples.rb +38 -0
- data/lib/cucumber/ast/feature.rb +62 -0
- data/lib/cucumber/ast/feature_element.rb +46 -0
- data/lib/cucumber/ast/features.rb +20 -0
- data/lib/cucumber/ast/outline_table.rb +81 -0
- data/lib/cucumber/ast/py_string.rb +58 -0
- data/lib/cucumber/ast/scenario.rb +64 -0
- data/lib/cucumber/ast/scenario_outline.rb +90 -0
- data/lib/cucumber/ast/step.rb +122 -0
- data/lib/cucumber/ast/step_collection.rb +66 -0
- data/lib/cucumber/ast/step_invocation.rb +110 -0
- data/lib/cucumber/ast/table.rb +318 -0
- data/lib/cucumber/ast/tags.rb +33 -0
- data/lib/cucumber/ast/visitor.rb +125 -0
- data/lib/cucumber/broadcaster.rb +2 -9
- data/lib/cucumber/cli/configuration.rb +364 -0
- data/lib/cucumber/cli/language_help_formatter.rb +59 -0
- data/lib/cucumber/cli/main.rb +109 -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 +13 -16
- data/lib/cucumber/formatter/color_io.rb +23 -0
- data/lib/cucumber/formatter/console.rb +109 -0
- data/lib/cucumber/formatter/cucumber.css +55 -0
- data/lib/cucumber/formatter/cucumber.sass +49 -0
- data/lib/cucumber/formatter/html.rb +133 -0
- data/lib/cucumber/formatter/pretty.rb +179 -0
- data/lib/cucumber/formatter/profile.rb +77 -0
- data/lib/cucumber/formatter/progress.rb +60 -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 +97 -0
- data/lib/cucumber/languages.yml +196 -80
- data/lib/cucumber/parser.rb +43 -0
- data/lib/cucumber/parser/basic.rb +0 -0
- data/lib/cucumber/parser/feature.rb +1487 -0
- data/lib/cucumber/parser/feature.tt +193 -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 +2 -17
- data/lib/cucumber/rails/rspec.rb +5 -9
- data/lib/cucumber/rails/world.rb +2 -2
- data/lib/cucumber/rake/task.rb +39 -7
- data/lib/cucumber/step_definition.rb +103 -0
- data/lib/cucumber/step_match.rb +49 -0
- data/lib/cucumber/step_mother.rb +183 -67
- data/lib/cucumber/version.rb +2 -2
- data/lib/cucumber/world.rb +53 -1
- data/rails_generators/cucumber/cucumber_generator.rb +22 -3
- data/rails_generators/cucumber/templates/cucumber +2 -1
- data/rails_generators/cucumber/templates/cucumber.rake +13 -5
- data/rails_generators/cucumber/templates/env.rb +4 -3
- data/rails_generators/cucumber/templates/paths.rb +18 -11
- data/rails_generators/cucumber/templates/webrat_steps.rb +41 -25
- data/rails_generators/feature/feature_generator.rb +4 -0
- data/rails_generators/feature/templates/steps.erb +0 -4
- data/spec/cucumber/ast/background_spec.rb +49 -0
- data/spec/cucumber/ast/feature_factory.rb +63 -0
- data/spec/cucumber/ast/feature_spec.rb +37 -0
- data/spec/cucumber/ast/py_string_spec.rb +47 -0
- data/spec/cucumber/ast/scenario_outline_spec.rb +67 -0
- data/spec/cucumber/ast/scenario_spec.rb +65 -0
- data/spec/cucumber/ast/step_collection_spec.rb +8 -0
- data/spec/cucumber/ast/step_spec.rb +66 -0
- data/spec/cucumber/ast/table_spec.rb +149 -0
- data/spec/cucumber/ast/tags_spec.rb +19 -0
- data/spec/cucumber/broadcaster_spec.rb +6 -18
- data/spec/cucumber/cli/configuration_spec.rb +275 -0
- data/spec/cucumber/cli/main_spec.rb +203 -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/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 +17 -16
- data/spec/cucumber/parser/feature_parser_spec.rb +282 -0
- data/spec/cucumber/parser/table_parser_spec.rb +48 -0
- data/spec/cucumber/step_definition_spec.rb +81 -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/multiple_tables.feature +6 -8
- 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 +165 -88
- data/examples/calculator_ruby_features/features/addition.rb +0 -39
- data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +0 -43
- data/examples/i18n/ja/README.txt +0 -5
- data/examples/selenium/features/step_definitons/stories_steps.rb +0 -40
- data/gem_tasks/treetop.rake +0 -41
- data/lib/cucumber/cli.rb +0 -356
- 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 -151
- 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_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/pending.rb +0 -22
- data/script/console +0 -10
- data/script/console.cmd +0 -1
- data/script/destroy +0 -14
- data/script/destroy.cmd +0 -1
- data/script/generate +0 -14
- data/script/generate.cmd +0 -1
- data/script/txt2html +0 -74
- data/script/txt2html.cmd +0 -1
- 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 -104
- 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/examples/i18n/ja/README.txt
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec/expectations'
|
2
|
-
require 'selenium'
|
3
|
-
|
4
|
-
class GoogleSearch
|
5
|
-
def initialize(browser)
|
6
|
-
@browser = browser
|
7
|
-
end
|
8
|
-
|
9
|
-
def goto
|
10
|
-
@browser.open 'http://www.google.com/'
|
11
|
-
end
|
12
|
-
|
13
|
-
def search(text)
|
14
|
-
@browser.type('q',text)
|
15
|
-
@browser.click 'btnG'
|
16
|
-
@browser.wait_for_page_to_load
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
Before do
|
21
|
-
@browser = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome", "http://localhost", 15000)
|
22
|
-
@browser.start
|
23
|
-
end
|
24
|
-
|
25
|
-
After do
|
26
|
-
@browser.stop
|
27
|
-
end
|
28
|
-
|
29
|
-
Given 'I am on the Google search page' do
|
30
|
-
@page = GoogleSearch.new(@browser)
|
31
|
-
@page.goto
|
32
|
-
end
|
33
|
-
|
34
|
-
When /I search for "(.*)"/ do |query|
|
35
|
-
@page.search(query)
|
36
|
-
end
|
37
|
-
|
38
|
-
Then /I should see a link to (.*)/ do |expected_url|
|
39
|
-
@browser.is_element_present("css=a[href='#{expected_url}']").should be_true
|
40
|
-
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,356 +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
|
-
@args.clear # Shut up RSpec
|
221
|
-
require "cucumber/treetop_parser/feature_#{@options[:lang]}"
|
222
|
-
require "cucumber/treetop_parser/feature_parser"
|
223
|
-
|
224
|
-
verbose_log("Ruby files required:")
|
225
|
-
files_to_require.each do |lib|
|
226
|
-
begin
|
227
|
-
require lib
|
228
|
-
verbose_log(" * #{lib}")
|
229
|
-
rescue LoadError => e
|
230
|
-
e.message << "\nFailed to load #{lib}"
|
231
|
-
raise e
|
232
|
-
end
|
233
|
-
end
|
234
|
-
verbose_log("\n")
|
235
|
-
end
|
236
|
-
|
237
|
-
def files_to_require
|
238
|
-
requires = @options[:require] || feature_dirs
|
239
|
-
files = requires.map do |path|
|
240
|
-
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
241
|
-
File.directory?(path) ? Dir["#{path}/**/*.rb"] : path
|
242
|
-
end.flatten.uniq
|
243
|
-
files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }
|
244
|
-
end
|
245
|
-
|
246
|
-
def feature_files
|
247
|
-
potential_feature_files = @paths.map do |path|
|
248
|
-
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
249
|
-
path = path.chomp('/')
|
250
|
-
File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
|
251
|
-
end.flatten.uniq
|
252
|
-
|
253
|
-
@options[:excludes].each do |exclude|
|
254
|
-
potential_feature_files.reject! do |path|
|
255
|
-
path =~ /#{Regexp.escape(exclude)}/
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
potential_feature_files
|
260
|
-
end
|
261
|
-
|
262
|
-
def feature_dirs
|
263
|
-
feature_files.map{|f| File.directory?(f) ? f : File.dirname(f)}.uniq
|
264
|
-
end
|
265
|
-
|
266
|
-
def load_plain_text_features(features)
|
267
|
-
parser = TreetopParser::FeatureParser.new
|
268
|
-
|
269
|
-
verbose_log("Features:")
|
270
|
-
feature_files.each do |f|
|
271
|
-
features << parser.parse_feature(f)
|
272
|
-
verbose_log(" * #{f}")
|
273
|
-
end
|
274
|
-
verbose_log("\n"*2)
|
275
|
-
end
|
276
|
-
|
277
|
-
def build_formatter_broadcaster(step_mother)
|
278
|
-
formatter_broadcaster = Broadcaster.new
|
279
|
-
@options[:formats].each do |format, output_list|
|
280
|
-
output_broadcaster = build_output_broadcaster(output_list)
|
281
|
-
case format
|
282
|
-
when 'pretty'
|
283
|
-
formatter_broadcaster.register(Formatters::PrettyFormatter.new(output_broadcaster, step_mother, @options))
|
284
|
-
when 'progress'
|
285
|
-
formatter_broadcaster.register(Formatters::ProgressFormatter.new(output_broadcaster))
|
286
|
-
when 'profile'
|
287
|
-
formatter_broadcaster.register(Formatters::ProfileFormatter.new(output_broadcaster, step_mother))
|
288
|
-
when 'html'
|
289
|
-
formatter_broadcaster.register(Formatters::HtmlFormatter.new(output_broadcaster, step_mother))
|
290
|
-
when 'autotest'
|
291
|
-
formatter_broadcaster.register(Formatters::AutotestFormatter.new(output_broadcaster))
|
292
|
-
else
|
293
|
-
begin
|
294
|
-
formatter_class = constantize(format)
|
295
|
-
formatter_broadcaster.register(formatter_class.new(output_broadcaster, step_mother, @options))
|
296
|
-
rescue NameError => e
|
297
|
-
@error_stream.puts "Invalid format: #{format}\n"
|
298
|
-
exit_with_help
|
299
|
-
rescue Exception => e
|
300
|
-
exit_with_error("Error creating formatter: #{format}\n#{e}\n")
|
301
|
-
end
|
302
|
-
end
|
303
|
-
end
|
304
|
-
formatter_broadcaster
|
305
|
-
end
|
306
|
-
|
307
|
-
def build_output_broadcaster(output_list)
|
308
|
-
output_broadcaster = Broadcaster.new
|
309
|
-
output_list.each do |output|
|
310
|
-
output_broadcaster.register(output)
|
311
|
-
end
|
312
|
-
output_broadcaster
|
313
|
-
end
|
314
|
-
|
315
|
-
private
|
316
|
-
|
317
|
-
def constantize(camel_cased_word)
|
318
|
-
names = camel_cased_word.split('::')
|
319
|
-
names.shift if names.empty? || names.first.empty?
|
320
|
-
|
321
|
-
constant = Object
|
322
|
-
names.each do |name|
|
323
|
-
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
324
|
-
end
|
325
|
-
constant
|
326
|
-
end
|
327
|
-
|
328
|
-
def verbose_log(string)
|
329
|
-
@out_stream.puts(string) if @options[:verbose]
|
330
|
-
end
|
331
|
-
|
332
|
-
def exit_with_help
|
333
|
-
parse_options!(%w{--help})
|
334
|
-
end
|
335
|
-
|
336
|
-
def exit_with_error(error_message)
|
337
|
-
@error_stream << error_message
|
338
|
-
Kernel.exit 1
|
339
|
-
end
|
340
|
-
|
341
|
-
def enable_diffing
|
342
|
-
if defined?(::Spec)
|
343
|
-
require 'spec/expectations/differs/default'
|
344
|
-
options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
|
345
|
-
::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
extend Cucumber::StepMethods
|
352
|
-
Cucumber::CLI.step_mother = step_mother
|
353
|
-
Cucumber::CLI.executor = executor
|
354
|
-
|
355
|
-
extend Cucumber::Tree
|
356
|
-
Cucumber::CLI.features = features
|