aslakhellesoy-cucumber 0.1.99.23 → 0.1.100.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/History.txt +2 -6
  2. data/Manifest.txt +8 -2
  3. data/examples/i18n/et/features/jagamine.feature +9 -0
  4. data/examples/jbehave/README.textile +4 -1
  5. data/examples/jbehave/features/trading.feature +4 -0
  6. data/examples/jbehave/pom.xml +5 -0
  7. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +6 -1
  8. data/examples/selenium/features/step_definitons/search_steps.rb +13 -0
  9. data/examples/selenium/features/support/env.rb +19 -0
  10. data/examples/selenium_webrat/Rakefile +6 -0
  11. data/examples/selenium_webrat/features/search.feature +9 -0
  12. data/examples/selenium_webrat/features/step_definitons/search_steps.rb +13 -0
  13. data/examples/selenium_webrat/features/support/env.rb +41 -0
  14. data/examples/self_test/features/background/failing_background.feature +1 -0
  15. data/examples/self_test/features/step_definitions/sample_steps.rb +1 -1
  16. data/examples/self_test/features/support/tag_count_formatter.rb +1 -1
  17. data/features/background.feature +9 -11
  18. data/features/cucumber_cli.feature +24 -1
  19. data/features/cucumber_cli_outlines.feature +10 -19
  20. data/features/report_called_undefined_steps.feature +2 -0
  21. data/gem_tasks/rspec.rake +2 -0
  22. data/lib/cucumber.rb +7 -15
  23. data/lib/cucumber/ast.rb +3 -3
  24. data/lib/cucumber/ast/background.rb +28 -66
  25. data/lib/cucumber/ast/examples.rb +15 -3
  26. data/lib/cucumber/ast/feature.rb +20 -24
  27. data/lib/cucumber/ast/feature_element.rb +46 -0
  28. data/lib/cucumber/ast/features.rb +2 -21
  29. data/lib/cucumber/ast/outline_table.rb +46 -14
  30. data/lib/cucumber/ast/py_string.rb +8 -3
  31. data/lib/cucumber/ast/scenario.rb +34 -73
  32. data/lib/cucumber/ast/scenario_outline.rb +40 -42
  33. data/lib/cucumber/ast/step.rb +53 -89
  34. data/lib/cucumber/ast/step_collection.rb +66 -0
  35. data/lib/cucumber/ast/step_invocation.rb +106 -0
  36. data/lib/cucumber/ast/table.rb +38 -19
  37. data/lib/cucumber/ast/tags.rb +4 -11
  38. data/lib/cucumber/ast/visitor.rb +31 -19
  39. data/lib/cucumber/broadcaster.rb +1 -1
  40. data/lib/cucumber/cli/configuration.rb +24 -16
  41. data/lib/cucumber/cli/language_help_formatter.rb +4 -4
  42. data/lib/cucumber/cli/main.rb +5 -4
  43. data/lib/cucumber/core_ext/proc.rb +2 -2
  44. data/lib/cucumber/formatter/ansicolor.rb +0 -1
  45. data/lib/cucumber/formatter/console.rb +18 -34
  46. data/lib/cucumber/formatter/html.rb +13 -10
  47. data/lib/cucumber/formatter/pretty.rb +48 -36
  48. data/lib/cucumber/formatter/profile.rb +6 -6
  49. data/lib/cucumber/formatter/progress.rb +12 -20
  50. data/lib/cucumber/formatter/rerun.rb +5 -5
  51. data/lib/cucumber/jbehave.rb +21 -26
  52. data/lib/cucumber/parser/feature.rb +26 -29
  53. data/lib/cucumber/parser/feature.tt +17 -12
  54. data/lib/cucumber/parser/treetop_ext.rb +13 -13
  55. data/lib/cucumber/platform.rb +0 -1
  56. data/lib/cucumber/rails/world.rb +2 -2
  57. data/lib/cucumber/rake/task.rb +0 -1
  58. data/lib/cucumber/step_definition.rb +21 -12
  59. data/lib/cucumber/step_match.rb +49 -0
  60. data/lib/cucumber/step_mother.rb +98 -80
  61. data/lib/cucumber/version.rb +2 -2
  62. data/lib/cucumber/world.rb +42 -0
  63. data/rails_generators/cucumber/templates/paths.rb +1 -1
  64. data/rails_generators/cucumber/templates/webrat_steps.rb +17 -17
  65. data/rails_generators/feature/feature_generator.rb +4 -0
  66. data/rails_generators/feature/templates/steps.erb +0 -4
  67. data/spec/cucumber/ast/background_spec.rb +32 -41
  68. data/spec/cucumber/ast/feature_factory.rb +10 -1
  69. data/spec/cucumber/ast/feature_spec.rb +7 -30
  70. data/spec/cucumber/ast/scenario_outline_spec.rb +3 -0
  71. data/spec/cucumber/ast/scenario_spec.rb +8 -25
  72. data/spec/cucumber/ast/step_collection_spec.rb +8 -0
  73. data/spec/cucumber/ast/step_spec.rb +37 -29
  74. data/spec/cucumber/ast/tags_spec.rb +2 -18
  75. data/spec/cucumber/cli/configuration_spec.rb +7 -0
  76. data/spec/cucumber/cli/main_spec.rb +1 -1
  77. data/spec/cucumber/parser/feature_parser_spec.rb +6 -5
  78. data/spec/cucumber/step_definition_spec.rb +5 -5
  79. data/spec/cucumber/step_mother_spec.rb +6 -6
  80. data/spec/cucumber/world/pending_spec.rb +1 -1
  81. metadata +17 -5
  82. data/lib/cucumber/ast/filter.rb +0 -22
  83. data/lib/cucumber/ast/steps.rb +0 -13
@@ -29,11 +29,20 @@ module Cucumber
29
29
  I like
30
30
  Cucumber sandwich
31
31
  }, 10)
32
+
33
+ background = Ast::Background.new(Ast::Comment.new(""), 2, "Background:",
34
+ [
35
+ Step.new(3, "Given", "a passing step")
36
+ ]
37
+ )
38
+
32
39
  f = Ast::Feature.new(
40
+ background,
33
41
  Ast::Comment.new("# My feature comment\n"),
34
42
  Ast::Tags.new(6, ['one', 'two']),
35
43
  "Pretty printing",
36
44
  [Ast::Scenario.new(
45
+ background,
37
46
  Ast::Comment.new(" # My scenario comment \n# On two lines \n"),
38
47
  Ast::Tags.new(8, ['three', 'four']),
39
48
  9,
@@ -46,7 +55,7 @@ module Cucumber
46
55
  )]
47
56
  )
48
57
  f.file = 'features/pretty_printing.feature'
49
- f.features = Features.new(Filter.new({:tags => []}))
58
+ f.features = Features.new
50
59
  f
51
60
  end
52
61
  end
@@ -14,46 +14,23 @@ module Cucumber
14
14
  [:comment, "# My feature comment\n"],
15
15
  [:tag, "one"],
16
16
  [:tag, "two"],
17
+ [:background, 2, 'Background:',
18
+ [:step, 3, "Given", "a passing step"]],
17
19
  [:scenario, 9, "Scenario:",
18
20
  "A Scenario",
19
21
  [:comment, " # My scenario comment \n# On two lines \n"],
20
22
  [:tag, "three"],
21
- [:tag, "four"],
22
- [:step, 10, "Given", "a passing step with an inline arg:",
23
+ [:tag, "four"],
24
+ [:step_invocation, 3, "Given", "a passing step"], # From the background
25
+ [:step_invocation, 10, "Given", "a passing step with an inline arg:",
23
26
  [:table,
24
27
  [:row,
25
28
  [:cell, "1"], [:cell, "22"], [:cell, "333"]],
26
29
  [:row,
27
30
  [:cell, "4444"], [:cell, "55555"], [:cell, "666666"]]]],
28
- [:step, 11, "Given", "a happy step with an inline arg:",
31
+ [:step_invocation, 11, "Given", "a happy step with an inline arg:",
29
32
  [:py_string, "\n I like\nCucumber sandwich\n"]],
30
- [:step, 12, "Given", "a failing step"]]]
31
- end
32
-
33
- it "should only visit scenarios that match" do
34
- s1 = mock("Scenario 1")
35
- s2 = mock("Scenario 2")
36
- s3 = mock("Scenario 3")
37
- [s1, s2, s3].each{|s| s.should_receive(:feature=)}
38
- f = Ast::Feature.new(
39
- Ast::Comment.new(""),
40
- Ast::Tags.new(22, []),
41
- "My feature",
42
- [s1, s2, s3]
43
- )
44
- features = mock('Features')
45
- f.features = features
46
-
47
- f.lines = [33]
48
-
49
- features.should_receive(:visit?).with(s1, [33]).and_return(false)
50
- features.should_receive(:visit?).with(s2, [33]).and_return(true)
51
- features.should_receive(:visit?).with(s3, [33]).and_return(false)
52
-
53
- s2.should_receive(:accept)
54
-
55
- visitor = Visitor.new(nil)
56
- visitor.visit_feature(f)
33
+ [:step_invocation, 12, "Given", "a failing step"]]]
57
34
  end
58
35
  end
59
36
  end
@@ -9,6 +9,7 @@ module Cucumber
9
9
  before do
10
10
  @step_mother = Object.new
11
11
  @step_mother.extend(StepMother)
12
+
12
13
  @step_mother.Given(/^there are (\d+) cucumbers$/) do |n|
13
14
  @initial = n.to_i
14
15
  end
@@ -23,6 +24,7 @@ module Cucumber
23
24
  end
24
25
 
25
26
  @scenario_outline = ScenarioOutline.new(
27
+ background=nil,
26
28
  Comment.new(""),
27
29
  Tags.new(18, []),
28
30
  19,
@@ -45,6 +47,7 @@ module Cucumber
45
47
  ]
46
48
  ]
47
49
  ]
50
+
48
51
  )
49
52
  end
50
53
 
@@ -9,9 +9,6 @@ module Cucumber
9
9
  @step_mother = Object.new
10
10
  @step_mother.extend(StepMother)
11
11
  $x = $y = nil
12
- @step_mother.Before do
13
- $x = 3
14
- end
15
12
  @step_mother.Given /y is (\d+)/ do |n|
16
13
  $y = n.to_i
17
14
  end
@@ -19,23 +16,9 @@ module Cucumber
19
16
  @visitor.options = {}
20
17
  end
21
18
 
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
19
  it "should skip steps when previous is not passed" do
38
20
  scenario = Scenario.new(
21
+ background=nil,
39
22
  comment=Comment.new(""),
40
23
  tags=Tags.new(98, []),
41
24
  line=99,
@@ -47,20 +30,20 @@ module Cucumber
47
30
  ])
48
31
  @visitor.visit_feature_element(scenario)
49
32
 
50
- $x.should == 3
51
33
  $y.should == nil
52
34
  end
53
35
 
54
36
  it "should be at exact line" do
55
- s = Scenario.new(comment=Comment.new(""),
37
+ s = Scenario.new(background=nil, comment=Comment.new(""),
56
38
  tags=Tags.new(44, []), 45, keyword="", name="", steps=[])
57
39
 
58
- s.should be_at_lines([44])
59
- s.should be_at_lines([45])
40
+ s.should be_matches_lines([44])
41
+ s.should be_matches_lines([45])
60
42
  end
61
43
 
62
44
  it "should be at line if tags or steps are" do
63
45
  s = Scenario.new(
46
+ background=nil,
64
47
  comment=Comment.new(""),
65
48
  tags=Tags.new(43, []),
66
49
  line=45,
@@ -73,9 +56,9 @@ module Cucumber
73
56
  ]
74
57
  )
75
58
 
76
- s.should be_at_lines([43])
77
- s.should be_at_lines([47])
78
- s.should_not be_at_lines([49])
59
+ s.should be_matches_lines([43])
60
+ s.should be_matches_lines([47])
61
+ s.should_not be_matches_lines([49])
79
62
  end
80
63
  end
81
64
  end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Cucumber
4
+ module Ast
5
+ describe StepCollection do
6
+ end
7
+ end
8
+ end
@@ -5,40 +5,48 @@ require 'cucumber/core_ext/string'
5
5
 
6
6
  module Cucumber
7
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')
8
+ describe Step do
9
+ it "should replace arguments in name" do
10
+ step = Step.new(1, 'Given', 'a <color> cucumber')
15
11
 
16
- step1.source_indent.should == 2
17
- step2.source_indent.should == 0
12
+ invocation_table = Table.new([
13
+ %w{color taste},
14
+ %w{green juicy}
15
+ ])
16
+ cells = invocation_table.cells_rows[1]
17
+ step_invocation = step.step_invocation_from_cells(cells)
18
+
19
+ step_invocation.name.should == 'a green cucumber'
18
20
  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
21
 
28
- mock_multiline_arg.should_receive(:arguments_replaced).with({'<test>' => '10'}).and_return(mock_multiline_arg)
22
+ it "should replace arguments in table arg" do
23
+ arg_table = Table.new([%w{taste_<taste> color_<color>}])
24
+
25
+ step = Step.new(1, 'Given', 'a <color> cucumber', arg_table)
26
+
27
+ invocation_table = Table.new([
28
+ %w{color taste},
29
+ %w{green juicy}
30
+ ])
31
+ cells = invocation_table.cells_rows[1]
32
+ step_invocation = step.step_invocation_from_cells(cells)
29
33
 
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)
34
+ step_invocation.instance_variable_get('@multiline_arg').raw.should == [%w{taste_juicy color_green}]
35
+ end
36
+
37
+ it "should replace arguments in py string arg" do
38
+ py_string = PyString.new(1, 2, 'taste_<taste> color_<color>', 0)
39
+
40
+ step = Step.new(1, 'Given', 'a <color> cucumber', py_string)
41
+
42
+ invocation_table = Table.new([
43
+ %w{color taste},
44
+ %w{green juicy}
45
+ ])
46
+ cells = invocation_table.cells_rows[1]
47
+ step_invocation = step.step_invocation_from_cells(cells)
38
48
 
39
- step.execute_with_arguments({'test' => '10'}, stub('world'), :passed, visitor=nil, line=-1)
40
- end
41
-
49
+ step_invocation.instance_variable_get('@multiline_arg').to_s.should == 'taste_juicy color_green'
42
50
  end
43
51
  end
44
52
  end
@@ -8,27 +8,11 @@ module Cucumber
8
8
  end
9
9
 
10
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
-
22
- it "should not be among other tags with @ prefix" do
23
- @tags.should_not be_among(%w{one ~@two})
24
- end
25
-
26
- it "should be among other tags with irrelevant negative tag" do
27
- @tags.should be_among(%w{~bacon})
11
+ @tags.should have_tags(%w{one})
28
12
  end
29
13
 
30
14
  it "should not be among other tags with irrelevent tag" do
31
- @tags.should_not be_among(%w{bacon})
15
+ @tags.should_not have_tags(%w{bacon})
32
16
  end
33
17
  end
34
18
  end
@@ -201,6 +201,13 @@ END_OF_MESSAGE
201
201
  config.parse!(['--no-color'])
202
202
  end
203
203
 
204
+ it "should parse tags" do
205
+ config = Configuration.new(nil)
206
+ includes, excludes = config.parse_tags("one,~two,@three,~@four")
207
+ includes.should == ['one', 'three']
208
+ excludes.should == ['two', 'four']
209
+ end
210
+
204
211
  describe "--backtrace" do
205
212
  before do
206
213
  Exception.cucumber_full_backtrace = false
@@ -25,7 +25,7 @@ module Cli
25
25
  describe "verbose mode" do
26
26
 
27
27
  before(:each) do
28
- @empty_feature = Ast::Feature.new(Ast::Comment.new(''), Ast::Tags.new(2, []), "Feature", [])
28
+ @empty_feature = Ast::Feature.new(nil, Ast::Comment.new(''), Ast::Tags.new(2, []), "Feature", [])
29
29
  Dir.stub!(:[])
30
30
  end
31
31
 
@@ -94,14 +94,15 @@ Feature: hi
94
94
  Given Pepper
95
95
 
96
96
  @st3
97
- @st4 @ST5 @#^%&ST6**!
97
+ @st4 @ST5 @#^%&ST6**!
98
98
  Scenario: Second}).to_sexp.should ==
99
99
  [:feature, "Feature: hi",
100
100
  [:comment, "# FC\n "],
101
101
  [:tag, "ft"],
102
102
  [:scenario, 6, 'Scenario:', 'First',
103
103
  [:tag, "st1"], [:tag, "st2"],
104
- [:step, 7, "Given", "Pepper"]],
104
+ [:step_invocation, 7, "Given", "Pepper"]
105
+ ],
105
106
  [:scenario, 11, 'Scenario:', 'Second',
106
107
  [:tag, "st3"], [:tag, "st4"], [:tag, "ST5"], [:tag, "#^%&ST6**!"]]]
107
108
  end
@@ -135,7 +136,7 @@ Scenario: bar
135
136
  parse("Feature: Hi\nScenario: Hello\nGiven I am a step\n").to_sexp.should ==
136
137
  [:feature, "Feature: Hi",
137
138
  [:scenario, 2, "Scenario:", "Hello",
138
- [:step, 3, "Given", "I am a step"]]]
139
+ [:step_invocation, 3, "Given", "I am a step"]]]
139
140
  end
140
141
 
141
142
  it "should have steps with inline table" do
@@ -146,7 +147,7 @@ Given I have a table
146
147
  }).to_sexp.should ==
147
148
  [:feature, "Feature: Hi",
148
149
  [:scenario, 2, "Scenario:", "Hello",
149
- [:step, 3, "Given", "I have a table",
150
+ [:step_invocation, 3, "Given", "I have a table",
150
151
  [:table,
151
152
  [:row,
152
153
  [:cell, "a"],
@@ -167,7 +168,7 @@ Given I have a string
167
168
  }).to_sexp.should ==
168
169
  [:feature, "Feature: Hi",
169
170
  [:scenario, 2, "Scenario:", "Hello",
170
- [:step, 3, "Given", "I have a string",
171
+ [:step_invocation, 3, "Given", "I have a string",
171
172
  [:py_string, "hello\nworld"]]]]
172
173
  end
173
174
  end
@@ -8,7 +8,7 @@ module Cucumber
8
8
  describe StepDefinition do
9
9
  before do
10
10
  extend StepMother
11
- @world = new_world
11
+ @world = new_world!
12
12
  $inside = nil
13
13
  end
14
14
 
@@ -20,7 +20,7 @@ module Cucumber
20
20
  $inside = true
21
21
  end
22
22
 
23
- step_definition("Outside").execute(nil, @world)
23
+ step_match("Outside").invoke(@world, nil)
24
24
  $inside.should == true
25
25
  end
26
26
 
@@ -32,7 +32,7 @@ module Cucumber
32
32
  $inside = table.raw[0][0]
33
33
  end
34
34
 
35
- step_definition("Outside").execute(nil, @world)
35
+ step_match("Outside").invoke(@world, nil)
36
36
  $inside.should == 'inside'
37
37
  end
38
38
 
@@ -45,7 +45,7 @@ module Cucumber
45
45
  step.should_receive(:exception=)
46
46
  lambda do
47
47
  @world.__cucumber_current_step = step
48
- step_definition('Outside').execute(nil, @world)
48
+ step_match('Outside').invoke(@world, nil)
49
49
  end.should raise_error(Undefined, 'Undefined step: "Inside"')
50
50
  end
51
51
 
@@ -55,7 +55,7 @@ module Cucumber
55
55
  end
56
56
 
57
57
  lambda do
58
- step_definition("Outside").execute(nil, @world)
58
+ step_match("Outside").invoke(@world, nil)
59
59
  end.should raise_error(Pending, "Do me!")
60
60
  end
61
61
 
@@ -15,7 +15,7 @@ module Cucumber
15
15
  end
16
16
  @step_mother.Given(/nope something else/) do |what, month|
17
17
  end
18
- format = @step_mother.step_definition("it snows in april").format_args("it snows in april", "[%s]")
18
+ format = @step_mother.step_match("it snows in april").format_args("[%s]")
19
19
  format.should == "it [snows] in [april]"
20
20
  end
21
21
 
@@ -24,7 +24,7 @@ module Cucumber
24
24
  @step_mother.Given(/Three blind (.*)/) {|animal|}
25
25
 
26
26
  lambda do
27
- @step_mother.step_definition("Three blind mice")
27
+ @step_mother.step_match("Three blind mice")
28
28
  end.should raise_error(Ambiguous, %{Ambiguous match of "Three blind mice":
29
29
 
30
30
  spec/cucumber/step_mother_spec.rb:23:in `/Three (.*) mice/'
@@ -39,7 +39,7 @@ spec/cucumber/step_mother_spec.rb:24:in `/Three blind (.*)/'
39
39
  @step_mother.Given(/Three (.*)/) {|animal|}
40
40
 
41
41
  lambda do
42
- @step_mother.step_definition("Three blind mice")
42
+ @step_mother.step_match("Three blind mice")
43
43
  end.should_not raise_error
44
44
  end
45
45
 
@@ -47,19 +47,19 @@ spec/cucumber/step_mother_spec.rb:24:in `/Three blind (.*)/'
47
47
  @step_mother.options = {:guess => true}
48
48
  right = @step_mother.Given(/Three (.*) mice/) {|disability|}
49
49
  wrong = @step_mother.Given(/Three (.*)/) {|animal|}
50
- @step_mother.step_definition("Three blind mice").should == right
50
+ @step_mother.step_match("Three blind mice").step_definition.should == right
51
51
  end
52
52
 
53
53
  it "should pick right step definition when --guess is enabled and unequal number of capture groups" do
54
54
  @step_mother.options = {:guess => true}
55
55
  right = @step_mother.Given(/Three (.*) mice ran (.*)/) {|disability|}
56
56
  wrong = @step_mother.Given(/Three (.*)/) {|animal|}
57
- @step_mother.step_definition("Three blind mice ran far").should == right
57
+ @step_mother.step_match("Three blind mice ran far").step_definition.should == right
58
58
  end
59
59
 
60
60
  it "should raise Undefined error when no step definitions match" do
61
61
  lambda do
62
- @step_mother.step_definition("Three blind mice")
62
+ @step_mother.step_match("Three blind mice")
63
63
  end.should raise_error(Undefined)
64
64
  end
65
65