kosmas58-cucumber 0.1.16.6 → 0.1.99.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +126 -2
- data/License.txt +1 -1
- data/Manifest.txt +0 -270
- data/Rakefile +1 -1
- data/bin/cucumber +2 -2
- data/config/hoe.rb +7 -2
- data/examples/cs/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/README.textile +1 -1
- data/examples/i18n/Rakefile +3 -3
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -6
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/de/features/addition.feature +6 -6
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/en/features/addition.feature +6 -6
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/es/features/adicion.feature +11 -12
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +7 -10
- data/examples/i18n/es/lib/calculador.rb +4 -1
- data/examples/i18n/et/features/liitmine.feature +7 -6
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +1 -1
- data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +1 -1
- data/examples/i18n/fi/features/yhteenlasku.feature +2 -2
- data/examples/i18n/fr/features/addition.feature +2 -2
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +1 -1
- data/examples/i18n/id/features/addition.feature +6 -6
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -1
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +2 -3
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/lt/features/addition.feature +7 -6
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +7 -7
- data/examples/i18n/no/features/summering.feature +1 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +1 -1
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/java/src/cucumber/demo/Hello.java +16 -0
- data/examples/jbehave/README.textile +17 -0
- data/examples/jbehave/features/support/env.rb +7 -0
- data/examples/jbehave/features/trading.feature +24 -0
- data/examples/jbehave/pom.xml +48 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java +32 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java +42 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java +29 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java +22 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +65 -0
- data/examples/self_test/README.textile +4 -1
- data/examples/{calculator_ruby_features → self_test}/Rakefile +3 -3
- data/examples/self_test/features/background/failing_background.feature +10 -0
- data/examples/self_test/features/background/failing_background_after_success.feature +11 -0
- data/examples/self_test/features/background/multiline_args_background.feature +32 -0
- data/examples/self_test/features/background/passing_background.feature +10 -0
- data/examples/self_test/features/background/pending_background.feature +10 -0
- data/examples/self_test/features/background/scenario_outline_failing_background.feature +16 -0
- data/examples/self_test/features/background/scenario_outline_passing_background.feature +16 -0
- data/examples/self_test/features/call_undefined_step_from_step_def.feature +7 -0
- data/examples/self_test/features/lots_of_undefined.feature +8 -0
- data/examples/self_test/features/outline_sample.feature +11 -5
- data/examples/self_test/features/sample.feature +8 -3
- data/examples/self_test/features/step_definitions/sample_steps.rb +53 -4
- data/examples/self_test/features/support/env.rb +1 -0
- data/examples/self_test/features/support/tag_count_formatter.rb +25 -0
- data/examples/tickets/features/172.feature +28 -0
- data/examples/tickets/features/177/1.feature +29 -0
- data/examples/tickets/features/177/2.feature +21 -0
- data/examples/tickets/features/177/3.feature +18 -0
- data/examples/tickets/features/180.feature +7 -0
- data/examples/tickets/features/scenario_outline.feature +6 -1
- data/examples/tickets/features/step_definitons/tickets_steps.rb +27 -3
- data/examples/tickets/features/tickets.feature +4 -0
- data/features/background.feature +223 -0
- data/features/cucumber_cli.feature +218 -98
- data/features/cucumber_cli_outlines.feature +54 -37
- data/features/custom_formatter.feature +11 -0
- data/features/report_called_undefined_steps.feature +32 -0
- data/features/step_definitions/cucumber_steps.rb +7 -3
- data/features/step_definitions/extra_steps.rb +1 -1
- data/features/support/env.rb +2 -1
- data/gem_tasks/flog.rake +1 -1
- data/gem_tasks/gemspec.rake +2 -2
- data/gem_tasks/jar.rake +67 -0
- data/lib/autotest/cucumber_mixin.rb +17 -23
- data/lib/cucumber.rb +63 -11
- data/lib/cucumber/ast.rb +29 -0
- data/lib/cucumber/ast/background.rb +88 -0
- data/lib/cucumber/ast/comment.rb +26 -0
- data/lib/cucumber/ast/examples.rb +26 -0
- data/lib/cucumber/ast/feature.rb +66 -0
- data/lib/cucumber/ast/features.rb +39 -0
- data/lib/cucumber/ast/filter.rb +22 -0
- data/lib/cucumber/ast/outline_table.rb +49 -0
- data/lib/cucumber/ast/py_string.rb +52 -0
- data/lib/cucumber/ast/scenario.rb +103 -0
- data/lib/cucumber/ast/scenario_outline.rb +92 -0
- data/lib/cucumber/ast/step.rb +161 -0
- data/lib/cucumber/ast/steps.rb +13 -0
- data/lib/cucumber/ast/table.rb +218 -0
- data/lib/cucumber/ast/tags.rb +40 -0
- data/lib/cucumber/ast/visitor.rb +109 -0
- data/lib/cucumber/broadcaster.rb +1 -6
- data/lib/cucumber/cli/configuration.rb +339 -0
- data/lib/cucumber/cli/language_help_formatter.rb +59 -0
- data/lib/cucumber/cli/main.rb +100 -0
- data/lib/cucumber/core_ext/exception.rb +41 -8
- data/lib/cucumber/core_ext/instance_exec.rb +54 -0
- data/lib/cucumber/core_ext/proc.rb +29 -65
- data/lib/cucumber/core_ext/string.rb +19 -0
- data/lib/cucumber/formatter.rb +1 -0
- data/lib/cucumber/{formatters → formatter}/ansicolor.rb +14 -16
- data/lib/cucumber/formatter/color_io.rb +17 -0
- data/lib/cucumber/formatter/console.rb +119 -0
- data/lib/cucumber/formatter/cucumber.css +55 -0
- data/lib/cucumber/formatter/cucumber.sass +49 -0
- data/lib/cucumber/formatter/html.rb +121 -0
- data/lib/cucumber/formatter/pretty.rb +167 -0
- data/lib/cucumber/formatter/profile.rb +77 -0
- data/lib/cucumber/formatter/progress.rb +68 -0
- data/lib/cucumber/formatter/rerun.rb +35 -0
- data/lib/cucumber/formatter/unicode.rb +35 -0
- data/lib/cucumber/formatters/unicode.rb +2 -35
- data/lib/cucumber/jbehave.rb +102 -0
- data/lib/cucumber/languages.yml +128 -75
- data/lib/cucumber/parser.rb +43 -0
- data/lib/cucumber/parser/basic.rb +0 -0
- data/lib/cucumber/parser/feature.rb +1490 -0
- data/lib/cucumber/parser/feature.tt +188 -0
- data/lib/cucumber/parser/i18n.tt +31 -0
- data/lib/cucumber/parser/table.rb +402 -0
- data/lib/cucumber/parser/table.tt +59 -0
- data/lib/cucumber/parser/treetop_ext.rb +75 -0
- data/lib/cucumber/platform.rb +3 -17
- data/lib/cucumber/rails/rspec.rb +5 -2
- data/lib/cucumber/step_definition.rb +87 -0
- data/lib/cucumber/step_mother.rb +151 -66
- data/lib/cucumber/version.rb +2 -2
- data/rails_generators/cucumber/USAGE +3 -2
- data/rails_generators/cucumber/cucumber_generator.rb +33 -23
- data/rails_generators/cucumber/templates/cucumber +2 -1
- data/rails_generators/cucumber/templates/cucumber.rake +6 -1
- data/rails_generators/cucumber/templates/env.rb +1 -1
- data/rails_generators/feature/USAGE +3 -0
- data/rails_generators/feature/feature_generator.rb +30 -6
- data/spec/cucumber/ast/background_spec.rb +58 -0
- data/spec/cucumber/ast/feature_factory.rb +54 -0
- data/spec/cucumber/ast/feature_spec.rb +60 -0
- data/spec/cucumber/ast/py_string_spec.rb +40 -0
- data/spec/cucumber/ast/scenario_outline_spec.rb +64 -0
- data/spec/cucumber/ast/scenario_spec.rb +82 -0
- data/spec/cucumber/ast/step_spec.rb +45 -0
- data/spec/cucumber/ast/table_spec.rb +81 -0
- data/spec/cucumber/ast/tags_spec.rb +23 -0
- data/spec/cucumber/broadcaster_spec.rb +4 -17
- data/spec/cucumber/cli/configuration_spec.rb +239 -0
- data/spec/cucumber/cli/main_spec.rb +164 -0
- data/spec/cucumber/core_ext/proc_spec.rb +27 -35
- data/spec/cucumber/core_ext/string_spec.rb +8 -0
- data/spec/cucumber/{formatters → formatter}/ansicolor_spec.rb +2 -2
- data/spec/cucumber/formatter/html/cucumber.css +37 -0
- data/spec/cucumber/formatter/html/cucumber.js +13 -0
- data/spec/cucumber/formatter/html/index.html +45 -0
- data/spec/cucumber/formatter/html/jquery-1.3.min.js +19 -0
- data/spec/cucumber/formatter/html/jquery.uitableedit.js +100 -0
- data/spec/cucumber/formatters/profile_formatter_spec.rb +17 -16
- data/spec/cucumber/parser/feature_parser_spec.rb +281 -0
- data/spec/cucumber/parser/table_parser_spec.rb +48 -0
- data/spec/cucumber/step_definition_spec.rb +62 -0
- data/spec/cucumber/step_mother_spec.rb +50 -51
- data/spec/cucumber/treetop_parser/empty_feature.feature +1 -1
- data/spec/cucumber/treetop_parser/scenario_outline.feature +1 -1
- data/spec/cucumber/treetop_parser/spaces.feature +3 -1
- data/spec/cucumber/treetop_parser/with_comments.feature +1 -1
- data/spec/cucumber/treetop_parser/with_tags.feature +18 -0
- data/spec/cucumber/world/pending_spec.rb +13 -12
- data/spec/spec_helper.rb +1 -1
- metadata +107 -79
- data/examples/calculator_ruby_features/features/addition.rb +0 -39
- data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +0 -43
- data/gem_tasks/treetop.rake +0 -41
- data/lib/cucumber/cli.rb +0 -355
- data/lib/cucumber/executor.rb +0 -205
- data/lib/cucumber/formatters.rb +0 -1
- data/lib/cucumber/formatters/autotest_formatter.rb +0 -23
- data/lib/cucumber/formatters/cucumber.css +0 -132
- data/lib/cucumber/formatters/cucumber.js +0 -11
- data/lib/cucumber/formatters/html_formatter.rb +0 -152
- data/lib/cucumber/formatters/jquery.js +0 -32
- data/lib/cucumber/formatters/pretty_formatter.rb +0 -285
- data/lib/cucumber/formatters/profile_formatter.rb +0 -92
- data/lib/cucumber/formatters/progress_formatter.rb +0 -61
- data/lib/cucumber/model.rb +0 -1
- data/lib/cucumber/model/table.rb +0 -32
- data/lib/cucumber/step_methods.rb +0 -49
- data/lib/cucumber/tree.rb +0 -16
- data/lib/cucumber/tree/feature.rb +0 -105
- data/lib/cucumber/tree/features.rb +0 -21
- data/lib/cucumber/tree/given_scenario.rb +0 -13
- data/lib/cucumber/tree/scenario.rb +0 -240
- data/lib/cucumber/tree/step.rb +0 -173
- data/lib/cucumber/tree/table.rb +0 -26
- data/lib/cucumber/tree/top_down_visitor.rb +0 -23
- data/lib/cucumber/treetop_parser/feature.treetop.erb +0 -254
- data/lib/cucumber/treetop_parser/feature_ar.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_cy.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_da.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_de.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en-lol.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_es.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_et.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_fi.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_fr.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_id.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_it.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ja.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ko.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_lt.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_nl.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_no.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_parser.rb +0 -36
- data/lib/cucumber/treetop_parser/feature_pl.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_pt.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ro.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ro2.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ru.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_se.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +0 -1951
- data/lib/cucumber/world.rb +0 -1
- data/lib/cucumber/world/pending.rb +0 -22
- data/setup.rb +0 -1585
- data/spec/cucumber/cli_spec.rb +0 -521
- data/spec/cucumber/executor_spec.rb +0 -382
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +0 -26
- data/spec/cucumber/formatters/features.html +0 -269
- data/spec/cucumber/formatters/html_formatter_spec.rb +0 -110
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +0 -410
- data/spec/cucumber/formatters/progress_formatter_spec.rb +0 -81
- data/spec/cucumber/model/table_spec.rb +0 -32
- data/spec/cucumber/tree/feature_spec.rb +0 -122
- data/spec/cucumber/tree/row_scenario_outline_spec.rb +0 -73
- data/spec/cucumber/tree/row_scenario_spec.rb +0 -55
- data/spec/cucumber/tree/row_step_outline_spec.rb +0 -38
- data/spec/cucumber/tree/scenario_outline_spec.rb +0 -50
- data/spec/cucumber/tree/scenario_spec.rb +0 -134
- data/spec/cucumber/tree/step_outline_spec.rb +0 -17
- data/spec/cucumber/tree/step_spec.rb +0 -59
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +0 -120
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/step_mother'
|
3
|
+
require 'cucumber/ast'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module Ast
|
7
|
+
describe Scenario do
|
8
|
+
before do
|
9
|
+
@step_mother = Object.new
|
10
|
+
@step_mother.extend(StepMother)
|
11
|
+
$x = $y = nil
|
12
|
+
@step_mother.Before do
|
13
|
+
$x = 3
|
14
|
+
end
|
15
|
+
@step_mother.Given /y is (\d+)/ do |n|
|
16
|
+
$y = n.to_i
|
17
|
+
end
|
18
|
+
@visitor = Visitor.new(@step_mother)
|
19
|
+
@visitor.options = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should execute Before blocks before steps" do
|
23
|
+
scenario = Scenario.new(
|
24
|
+
comment=Comment.new(""),
|
25
|
+
tags=Tags.new(98,[]),
|
26
|
+
line=99,
|
27
|
+
keyword="",
|
28
|
+
name="",
|
29
|
+
steps=[
|
30
|
+
Step.new(7, "Given", "y is 5")
|
31
|
+
])
|
32
|
+
@visitor.visit_feature_element(scenario)
|
33
|
+
$x.should == 3
|
34
|
+
$y.should == 5
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should skip steps when previous is not passed" do
|
38
|
+
scenario = Scenario.new(
|
39
|
+
comment=Comment.new(""),
|
40
|
+
tags=Tags.new(98, []),
|
41
|
+
line=99,
|
42
|
+
keyword="",
|
43
|
+
name="",
|
44
|
+
steps=[
|
45
|
+
Step.new(7, "Given", "this is missing"),
|
46
|
+
Step.new(8, "Given", "y is 5")
|
47
|
+
])
|
48
|
+
@visitor.visit_feature_element(scenario)
|
49
|
+
|
50
|
+
$x.should == 3
|
51
|
+
$y.should == nil
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should be at exact line" do
|
55
|
+
s = Scenario.new(comment=Comment.new(""),
|
56
|
+
tags=Tags.new(44, []), 45, keyword="", name="", steps=[])
|
57
|
+
|
58
|
+
s.should be_at_lines([44])
|
59
|
+
s.should be_at_lines([45])
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should be at line if tags or steps are" do
|
63
|
+
s = Scenario.new(
|
64
|
+
comment=Comment.new(""),
|
65
|
+
tags=Tags.new(43, []),
|
66
|
+
line=45,
|
67
|
+
keyword="",
|
68
|
+
name="",
|
69
|
+
steps=[
|
70
|
+
Step.new(46, "Given", ""),
|
71
|
+
Step.new(47, "Given", ""),
|
72
|
+
Step.new(48, "Given", ""),
|
73
|
+
]
|
74
|
+
)
|
75
|
+
|
76
|
+
s.should be_at_lines([43])
|
77
|
+
s.should be_at_lines([47])
|
78
|
+
s.should_not be_at_lines([49])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/step_mother'
|
3
|
+
require 'cucumber/ast'
|
4
|
+
require 'cucumber/core_ext/string'
|
5
|
+
|
6
|
+
module Cucumber
|
7
|
+
module Ast
|
8
|
+
describe StepMother do
|
9
|
+
it "should calculate comment padding" do
|
10
|
+
scenario = Scenario.new(comment=nil, tags=nil, line=nil, keyword='Given', name='Gazpacho', steps=[
|
11
|
+
Step.new(22, "Given", "tøtal 13"),
|
12
|
+
Step.new(23, "And", "the total 15")
|
13
|
+
])
|
14
|
+
step1, step2 = *scenario.instance_variable_get('@steps')
|
15
|
+
|
16
|
+
step1.source_indent.should == 2
|
17
|
+
step2.source_indent.should == 0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe Step do
|
22
|
+
describe "execute step with arguments" do
|
23
|
+
|
24
|
+
it "should replace arguments in multiline args" do
|
25
|
+
mock_multiline_arg = mock('multiline arg')
|
26
|
+
step = Step.new(23, 'Given', '<test>', mock_multiline_arg)
|
27
|
+
|
28
|
+
mock_multiline_arg.should_receive(:arguments_replaced).with({'<test>' => '10'}).and_return(mock_multiline_arg)
|
29
|
+
|
30
|
+
step.execute_with_arguments({'test' => '10'}, stub('world'), :passed, visitor=nil, line=-1)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should invoke step with replaced multiline args" do
|
34
|
+
mock_step_definition = mock('step definition')
|
35
|
+
mock_multiline_arg_replaced = mock('multiline arg replaced')
|
36
|
+
mock_multiline_arg = mock('multiline arg', :arguments_replaced => mock_multiline_arg_replaced)
|
37
|
+
step = Step.new(45, 'Given', '<test>', mock_multiline_arg)
|
38
|
+
|
39
|
+
step.execute_with_arguments({'test' => '10'}, stub('world'), :passed, visitor=nil, line=-1)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/ast/table'
|
3
|
+
|
4
|
+
module Cucumber
|
5
|
+
module Ast
|
6
|
+
describe Table do
|
7
|
+
before do
|
8
|
+
@table = Table.new([
|
9
|
+
%w{1 22 333},
|
10
|
+
%w{4444 55555 666666}
|
11
|
+
])
|
12
|
+
@table.extend(Module.new{
|
13
|
+
attr_reader :raw
|
14
|
+
})
|
15
|
+
def @table.cells_rows; super; end
|
16
|
+
def @table.columns; super; end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have rows" do
|
20
|
+
@table.cells_rows[0].map{|cell| cell.value}.should == %w{1 22 333}
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have columns" do
|
24
|
+
@table.columns[1].map{|cell| cell.value}.should == %w{22 55555}
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have same cell objects in rows and columns" do
|
28
|
+
# 666666
|
29
|
+
@table.cells_rows[1].__send__(:[], 2).should equal(@table.columns[2].__send__(:[], 1))
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should know about max width of a row" do
|
33
|
+
@table.columns[1].__send__(:width).should == 5
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be convertible to an array of hashes" do
|
37
|
+
@table.hashes.should == [
|
38
|
+
{'1' => '4444', '22' => '55555', '333' => '666666'}
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "replacing arguments" do
|
43
|
+
|
44
|
+
before(:each) do
|
45
|
+
@table = table = Table.new([
|
46
|
+
%w{qty book},
|
47
|
+
%w{<qty> <book>}
|
48
|
+
])
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return a new table with arguments replaced with values" do
|
52
|
+
table_with_replaced_args = @table.arguments_replaced({'<book>' => 'Unbearable lightness of being', '<qty>' => '5'})
|
53
|
+
|
54
|
+
table_with_replaced_args.hashes[0]['book'].should == 'Unbearable lightness of being'
|
55
|
+
table_with_replaced_args.hashes[0]['qty'].should == '5'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should not change the original table" do
|
59
|
+
table_with_replaced_args = @table.arguments_replaced({'<book>' => 'Unbearable lightness of being'})
|
60
|
+
|
61
|
+
@table.hashes[0]['book'].should_not == 'Unbearable lightness of being'
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should convert to sexp" do
|
67
|
+
@table.to_sexp.should ==
|
68
|
+
[:table,
|
69
|
+
[:row,
|
70
|
+
[:cell, "1"],
|
71
|
+
[:cell, "22"],
|
72
|
+
[:cell, "333"]
|
73
|
+
],
|
74
|
+
[:row,
|
75
|
+
[:cell, "4444"],
|
76
|
+
[:cell, "55555"],
|
77
|
+
[:cell, "666666"]]]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Ast
|
5
|
+
describe Tags do
|
6
|
+
before do
|
7
|
+
@tags = Tags.new(-1, %w{one two three})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be among other tags" do
|
11
|
+
@tags.should be_among(%w{one})
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be among other tags even with @ prefix" do
|
15
|
+
@tags.should be_among(%w{@one})
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should not be among other tags" do
|
19
|
+
@tags.should_not be_among(%w{one !two})
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -4,24 +4,11 @@ module Cucumber
|
|
4
4
|
describe Broadcaster do
|
5
5
|
|
6
6
|
it "should broadcast methods to registered objects" do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
mock_receiver.should_receive(:konbanwa).with('good evening')
|
11
|
-
broadcaster.register(mock_receiver)
|
12
|
-
|
13
|
-
broadcaster.konbanwa('good evening')
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should not call methods on registered objects if they dont support the method" do
|
17
|
-
broadcaster = Broadcaster.new
|
18
|
-
mock_receiver = mock('receiver', :respond_to? => false)
|
7
|
+
receiver = mock('receiver')
|
8
|
+
broadcaster = Broadcaster.new([receiver])
|
19
9
|
|
20
|
-
|
21
|
-
broadcaster.
|
22
|
-
|
23
|
-
broadcaster.konbanwa()
|
10
|
+
receiver.should_receive(:konbanwa).with('good evening')
|
11
|
+
broadcaster.konbanwa('good evening')
|
24
12
|
end
|
25
|
-
|
26
13
|
end
|
27
14
|
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Cucumber
|
5
|
+
module Cli
|
6
|
+
describe Configuration do
|
7
|
+
|
8
|
+
def given_cucumber_yml_defined_as(hash_or_string)
|
9
|
+
File.stub!(:exist?).and_return(true)
|
10
|
+
cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string
|
11
|
+
IO.stub!(:read).with('cucumber.yml').and_return(cucumber_yml)
|
12
|
+
end
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
Kernel.stub!(:exit).and_return(nil)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should require files in support paths first" do
|
19
|
+
File.stub!(:directory?).and_return(true)
|
20
|
+
Dir.stub!(:[]).and_return(["/features/step_definitions/foo.rb","/features/support/env.rb"])
|
21
|
+
|
22
|
+
config = Configuration.new(StringIO.new)
|
23
|
+
config.parse!(%w{--require /features})
|
24
|
+
|
25
|
+
config.files_to_require.should == [
|
26
|
+
"/features/support/env.rb",
|
27
|
+
"/features/step_definitions/foo.rb"
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should expand args from YAML file" do
|
32
|
+
given_cucumber_yml_defined_as({'bongo' => '--require from/yml'})
|
33
|
+
|
34
|
+
config = Configuration.new
|
35
|
+
config.parse!(%w{--format progress --profile bongo})
|
36
|
+
config.options[:formats].should == {'progress' => STDOUT}
|
37
|
+
config.options[:require].should == ['from/yml']
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should expand args from YAML file's default if there are no args" do
|
41
|
+
given_cucumber_yml_defined_as({'default' => '--require from/yml'})
|
42
|
+
|
43
|
+
config = Configuration.new
|
44
|
+
config.parse!([])
|
45
|
+
config.options[:require].should == ['from/yml']
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should provide a helpful error message when a specified profile does not exists in YAML file" do
|
49
|
+
given_cucumber_yml_defined_as({'default' => '--require from/yml', 'html_report' => '--format html'})
|
50
|
+
|
51
|
+
config = Configuration.new(StringIO.new, error = StringIO.new)
|
52
|
+
config.parse!(%w{--profile i_do_not_exist})
|
53
|
+
|
54
|
+
expected_message = <<-END_OF_MESSAGE
|
55
|
+
Could not find profile: 'i_do_not_exist'
|
56
|
+
|
57
|
+
Defined profiles in cucumber.yml:
|
58
|
+
* default
|
59
|
+
* html_report
|
60
|
+
END_OF_MESSAGE
|
61
|
+
|
62
|
+
error.string.should == expected_message
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should provide a helpful error message when a specified profile is not a String" do
|
66
|
+
given_cucumber_yml_defined_as({'foo' => [1,2,3]})
|
67
|
+
|
68
|
+
config = Configuration.new(StringIO.new, error = StringIO.new)
|
69
|
+
config.parse!(%w{--profile foo})
|
70
|
+
|
71
|
+
error.string.should == "Profiles must be defined as a String. The 'foo' profile was [1, 2, 3] (Array).\n"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should provide a helpful error message when a specified profile exists but is nil or blank" do
|
75
|
+
[nil, ' '].each do |bad_input|
|
76
|
+
given_cucumber_yml_defined_as({'foo' => bad_input})
|
77
|
+
|
78
|
+
config = Configuration.new(StringIO.new, error = StringIO.new)
|
79
|
+
config.parse!(%w{--profile foo})
|
80
|
+
|
81
|
+
error.string.should match(/The 'foo' profile in cucumber.yml was blank. Please define the command line arguments for the 'foo' profile in cucumber.yml./)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should provide a helpful error message when no YAML file exists and a profile is specified" do
|
86
|
+
File.should_receive(:exist?).with('cucumber.yml').and_return(false)
|
87
|
+
|
88
|
+
config = Configuration.new(StringIO.new, error = StringIO.new)
|
89
|
+
config.parse!(%w{--profile i_do_not_exist})
|
90
|
+
|
91
|
+
error.string.should match(/cucumber.yml was not found. Please refer to cucumber's documentaion on defining profiles in cucumber.yml./)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should provide a helpful error message when cucumber.yml is blank or malformed" do
|
95
|
+
expected_error_message = /cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentaion on correct profile usage./
|
96
|
+
|
97
|
+
['', 'sfsadfs', "--- \n- an\n- array\n", "---dddfd"].each do |bad_input|
|
98
|
+
given_cucumber_yml_defined_as(bad_input)
|
99
|
+
|
100
|
+
config = Configuration.new(StringIO.new, error = StringIO.new)
|
101
|
+
config.parse!([])
|
102
|
+
|
103
|
+
error.string.should match(expected_error_message)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should procide a helpful error message when the YAML can not be parsed" do
|
108
|
+
expected_error_message = /cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentaion on correct profile usage./
|
109
|
+
|
110
|
+
given_cucumber_yml_defined_as("input that causes an exception in YAML loading")
|
111
|
+
YAML.should_receive(:load).and_raise Exception
|
112
|
+
|
113
|
+
config = Configuration.new(StringIO.new, error = StringIO.new)
|
114
|
+
config.parse!([])
|
115
|
+
|
116
|
+
error.string.should match(expected_error_message)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should accept --dry-run option" do
|
120
|
+
config = Configuration.new(StringIO.new)
|
121
|
+
config.parse!(%w{--dry-run})
|
122
|
+
config.options[:dry_run].should be_true
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should accept --no-source option" do
|
126
|
+
config = Configuration.new
|
127
|
+
config.parse!(%w{--no-source})
|
128
|
+
|
129
|
+
config.options[:source].should be_false
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should accept --no-snippets option" do
|
133
|
+
config = Configuration.new
|
134
|
+
config.parse!(%w{--no-snippets})
|
135
|
+
|
136
|
+
config.options[:snippets].should be_false
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should set snippets and source to false with --quiet option" do
|
140
|
+
config = Configuration.new
|
141
|
+
config.parse!(%w{--quiet})
|
142
|
+
|
143
|
+
config.options[:snippets].should be_nil
|
144
|
+
config.options[:source].should be_nil
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should accept --verbose option" do
|
148
|
+
config = Configuration.new
|
149
|
+
config.parse!(%w{--verbose})
|
150
|
+
|
151
|
+
config.options[:verbose].should be_true
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should accept --out option" do
|
155
|
+
config = Configuration.new(StringIO.new)
|
156
|
+
config.parse!(%w{--out jalla.txt})
|
157
|
+
config.options[:formats]['pretty'].should == 'jalla.txt'
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should accept multiple --out options" do
|
161
|
+
config = Configuration.new(StringIO.new)
|
162
|
+
config.parse!(%w{--format progress --out file1 --out file2})
|
163
|
+
config.options[:formats].should == {'progress' => 'file2'}
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should accept multiple --format options" do
|
167
|
+
config = Configuration.new(StringIO.new)
|
168
|
+
config.parse!(%w{--format pretty --format progress})
|
169
|
+
config.options[:formats].should have_key('pretty')
|
170
|
+
config.options[:formats].should have_key('progress')
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should associate --out to previous --format" do
|
174
|
+
config = Configuration.new(StringIO.new)
|
175
|
+
config.parse!(%w{--format progress --out file1 --format profile --out file2})
|
176
|
+
config.options[:formats].should == {"profile"=>"file2", "progress"=>"file1"}
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should accept --color option" do
|
180
|
+
Term::ANSIColor.should_receive(:coloring=).with(true)
|
181
|
+
config = Configuration.new(StringIO.new)
|
182
|
+
config.parse!(['--color'])
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should accept --no-color option" do
|
186
|
+
Term::ANSIColor.should_receive(:coloring=).with(false)
|
187
|
+
config = Configuration.new(StringIO.new)
|
188
|
+
config.parse!(['--no-color'])
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "--backtrace" do
|
192
|
+
before do
|
193
|
+
Exception.cucumber_full_backtrace = false
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should show full backtrace when --backtrace is present" do
|
197
|
+
config = Main.new(['--backtrace'])
|
198
|
+
begin
|
199
|
+
"x".should == "y"
|
200
|
+
rescue => e
|
201
|
+
e.backtrace[0].should_not == "#{__FILE__}:#{__LINE__ - 2}"
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
xit "should strip gems when --backtrace is absent" do
|
206
|
+
config = Main.new(['--'])
|
207
|
+
begin
|
208
|
+
"x".should == "y"
|
209
|
+
rescue => e
|
210
|
+
e.backtrace[0].should == "#{__FILE__}:#{__LINE__ - 2}"
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
after do
|
215
|
+
Exception.cucumber_full_backtrace = false
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should accept multiple --scenario options" do
|
220
|
+
config = Configuration.new
|
221
|
+
config.parse!(['--scenario', "User logs in", '--scenario', "User signs up"])
|
222
|
+
|
223
|
+
config.options[:scenario_names].should include("User logs in")
|
224
|
+
config.options[:scenario_names].should include("User signs up")
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should search for all features in the specified directory" do
|
228
|
+
File.stub!(:directory?).and_return(true)
|
229
|
+
Dir.should_receive(:[]).with("feature_directory/**/*.feature").any_number_of_times.and_return(["cucumber.feature"])
|
230
|
+
|
231
|
+
config = Configuration.new(StringIO)
|
232
|
+
config.parse!(%w{feature_directory/})
|
233
|
+
|
234
|
+
config.feature_files.should == ["cucumber.feature"]
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|