cucumber 0.1.6 → 0.1.7

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.
Files changed (44) hide show
  1. data/History.txt +53 -0
  2. data/Manifest.txt +4 -0
  3. data/Rakefile +1 -0
  4. data/examples/calculator/cucumber.yml +1 -1
  5. data/examples/dos_line_endings/Rakefile +6 -0
  6. data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
  7. data/examples/tickets/features/steps/tickets_steps.rb +13 -1
  8. data/examples/tickets/features/tickets.feature +5 -1
  9. data/gem_tasks/treetop.rake +10 -0
  10. data/generators/cucumber/templates/common_webrat.rb +1 -1
  11. data/lib/cucumber.rb +3 -1
  12. data/lib/cucumber/cli.rb +16 -15
  13. data/lib/cucumber/core_ext/proc.rb +11 -2
  14. data/lib/cucumber/executor.rb +32 -15
  15. data/lib/cucumber/formatters/ansicolor.rb +25 -3
  16. data/lib/cucumber/formatters/pretty_formatter.rb +44 -15
  17. data/lib/cucumber/languages.yml +10 -0
  18. data/lib/cucumber/step_methods.rb +8 -4
  19. data/lib/cucumber/step_mother.rb +4 -3
  20. data/lib/cucumber/tree/scenario.rb +22 -10
  21. data/lib/cucumber/tree/step.rb +9 -1
  22. data/lib/cucumber/treetop_parser/feature.treetop.erb +5 -5
  23. data/lib/cucumber/treetop_parser/feature_da.rb +146 -108
  24. data/lib/cucumber/treetop_parser/feature_de.rb +146 -108
  25. data/lib/cucumber/treetop_parser/feature_en.rb +146 -108
  26. data/lib/cucumber/treetop_parser/feature_es.rb +146 -108
  27. data/lib/cucumber/treetop_parser/feature_et.rb +146 -108
  28. data/lib/cucumber/treetop_parser/feature_fr.rb +146 -108
  29. data/lib/cucumber/treetop_parser/feature_no.rb +146 -108
  30. data/lib/cucumber/treetop_parser/feature_parser.rb +4 -2
  31. data/lib/cucumber/treetop_parser/feature_pt.rb +146 -108
  32. data/lib/cucumber/treetop_parser/feature_ru.rb +146 -108
  33. data/lib/cucumber/treetop_parser/feature_se.rb +146 -108
  34. data/lib/cucumber/version.rb +1 -1
  35. data/spec/cucumber/cli_spec.rb +14 -4
  36. data/spec/cucumber/executor_spec.rb +4 -3
  37. data/spec/cucumber/formatters/ansicolor_spec.rb +4 -0
  38. data/spec/cucumber/formatters/pretty_formatter_spec.rb +67 -2
  39. data/spec/cucumber/tree/scenario_spec.rb +2 -2
  40. data/spec/cucumber/tree/step_spec.rb +21 -0
  41. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +5 -0
  42. data/spec/cucumber/treetop_parser/test_dos.feature +24 -0
  43. data/spec/spec_helper.rb +1 -7
  44. metadata +6 -2
@@ -2,7 +2,7 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 6
5
+ TINY = 7
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -9,12 +9,13 @@ module Cucumber
9
9
  cucumber_yml = {'bongo' => '--require from/yml'}.to_yaml
10
10
  IO.should_receive(:read).with('cucumber.yml').and_return(cucumber_yml)
11
11
 
12
- cli.parse_options!(%w{--format pretty --profile bongo})
12
+ cli.parse_options!(%w{--format progress --profile bongo})
13
13
  cli.options.should == {
14
- :format => 'pretty',
14
+ :format => 'progress',
15
15
  :require => ['from/yml'],
16
16
  :dry_run => false,
17
- :lang => 'en'
17
+ :lang => 'en',
18
+ :source => true
18
19
  }
19
20
  end
20
21
 
@@ -29,8 +30,17 @@ module Cucumber
29
30
  :format => 'pretty',
30
31
  :require => ['from/yml'],
31
32
  :dry_run => false,
32
- :lang => 'en'
33
+ :lang => 'en',
34
+ :source => true
33
35
  }
34
36
  end
37
+
38
+ it "should accept source option" do
39
+ cli = CLI.new
40
+ cli.parse_options!(%w{--no-source})
41
+
42
+ cli.options[:source].should be_false
43
+ end
44
+
35
45
  end
36
46
  end
@@ -5,9 +5,10 @@ module Cucumber
5
5
  describe Executor do
6
6
  before do # TODO: Way more setup and duplication of lib code. Use lib code!
7
7
  @io = StringIO.new
8
- @formatter = Formatters::ProgressFormatter.new(@io)
9
8
  @step_mother = StepMother.new
10
- @executor = Executor.new(@formatter, @step_mother)
9
+ @executor = Executor.new(@step_mother)
10
+ @formatter = Formatters::ProgressFormatter.new(@io)
11
+ @executor.formatter = @formatter
11
12
  @feature_file = File.dirname(__FILE__) + '/sell_cucumbers.feature'
12
13
  @parser = TreetopParser::FeatureParser.new
13
14
  @features = Tree::Features.new
@@ -37,7 +38,7 @@ STDOUT
37
38
 
38
39
  1)
39
40
  dang
40
- #{__FILE__}:33:in `Then /I should owe (\\d*) cucumbers/'
41
+ #{__FILE__}:34:in `Then /I should owe (\\d*) cucumbers/'
41
42
  #{@feature_file}:9:in `Then I should owe 7 cucumbers'
42
43
  \e[0m
43
44
  STDOUT
@@ -13,6 +13,10 @@ module Cucumber
13
13
  it "should return bold green without wrapping for #passed without arg" do
14
14
  passed.should == "\e[0m\e[1m\e[32m"
15
15
  end
16
+
17
+ it "should return grey for #comment" do
18
+ comment("foo").should == "\e[0m\e[90mfoo\e[0m"
19
+ end
16
20
 
17
21
  it "should not generate ansi codes when colors are disabled" do
18
22
  ENV['CUCUMBER_COLORS_DISABLED'] = '1'
@@ -3,15 +3,80 @@ require File.dirname(__FILE__) + '/../../spec_helper'
3
3
  module Cucumber
4
4
  module Formatters
5
5
  describe PrettyFormatter do
6
+
7
+ def mock_step(stubs={})
8
+ stub('step', {
9
+ :keyword => 'Given',
10
+ :format => 'formatted yes',
11
+ :name => 'example',
12
+ :error => nil,
13
+ :row? => false}.merge(stubs))
14
+ end
15
+
16
+ def mock_error(stubs={})
17
+ stub('error', {
18
+ :message => 'failed',
19
+ :backtrace => 'example backtrace'}.merge(stubs))
20
+ end
21
+
22
+ def mock_proc
23
+ stub(Proc, :to_comment_line => '# steps/example_steps.rb:11')
24
+ end
25
+
6
26
  it "should print step file and line when passed" do
7
27
  io = StringIO.new
8
- formatter = PrettyFormatter.new io
28
+ formatter = PrettyFormatter.new io, StepMother.new
9
29
  step = stub('step',
10
30
  :error => nil, :row? => false, :keyword => 'Given', :format => 'formatted yes'
11
31
  )
12
- formatter.step_passed(step,nil,nil)
32
+ formatter.step_passed(step, nil, nil)
13
33
  io.string.should == " Given formatted yes\n"
14
34
  end
35
+
36
+ describe "show source option true" do
37
+
38
+ %w{passed failed skipped}.each do |result|
39
+ it "should display step source for passed step" do
40
+ io = StringIO.new
41
+
42
+ step_mother = mock('step_mother')
43
+ formatter = PrettyFormatter.new io, step_mother, :source => true
44
+ formatter.send("step_#{result}".to_sym, mock_step(:regexp_args_proc => [nil, nil, mock_proc], :error => StandardError.new, :padding_length => 2), nil, nil)
45
+
46
+ io.string.should include("Given formatted yes # steps/example_steps.rb:11")
47
+ end
48
+ end
49
+
50
+ it "should align step comments" do
51
+ io = StringIO.new
52
+
53
+ step_1 = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :format => "1", :padding_length => 10)
54
+ step_4 = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :format => "4444", :padding_length => 7)
55
+ step_9 = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :format => "999999999", :padding_length => 2)
56
+
57
+ step_mother = mock('step_mother')
58
+ formatter = PrettyFormatter.new io, step_mother, :source => true
59
+
60
+ formatter.step_passed(step_1, nil, nil)
61
+ formatter.step_passed(step_4, nil, nil)
62
+ formatter.step_passed(step_9, nil, nil)
63
+
64
+ io.string.should include("Given 1 # steps/example_steps.rb:11")
65
+ io.string.should include("Given 4444 # steps/example_steps.rb:11")
66
+ io.string.should include("Given 999999999 # steps/example_steps.rb:11")
67
+ end
68
+
69
+ it "should NOT display step source for pending step" do
70
+ io = StringIO.new
71
+ step_mother = mock('step_mother')
72
+
73
+ formatter = PrettyFormatter.new io, step_mother, :source => true
74
+ formatter.step_pending(mock_step(:regexp_args_proc => [nil, nil, mock_proc]), nil, nil)
75
+
76
+ io.string.should_not include("steps/example_steps.rb:11")
77
+ end
78
+
79
+ end
15
80
  end
16
81
  end
17
82
  end
@@ -6,8 +6,8 @@ module Cucumber
6
6
  xit "should reuse steps in GivenScenario" do
7
7
  given_scenario = GivenScenario.new(scenario_2, "First", 99)
8
8
 
9
- scenario_2.add_step(given_scenario)
10
- scenario_2.add_step(step_a)
9
+ scenario_2.create_step(given_scenario)
10
+ scenario_2.create_step(step_a)
11
11
  scenario_2.steps.should == [step_1, step_2, step_a]
12
12
  end
13
13
  end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Cucumber
4
+ module Tree
5
+ describe Step do
6
+ it "should have padding_length 2 when alone" do
7
+ scenario = Scenario.new(nil, nil)
8
+ step = scenario.create_step('Given', '666666', 98)
9
+ step.padding_length.should == 2
10
+ end
11
+
12
+ it "should have padding_length 5 when 3 shorter" do
13
+ scenario = Scenario.new(nil, nil)
14
+ long = scenario.create_step('Given', '999999999', 80)
15
+ step = scenario.create_step('Given', '666666', 98)
16
+ step.padding_length.should == 5
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -68,6 +68,11 @@ module Cucumber
68
68
  f.should have(0).scenarios
69
69
  end
70
70
 
71
+ it "should parse features with dos line endings" do
72
+ p = FeatureParser.new
73
+ f = p.parse_feature(File.dirname(__FILE__) + '/test_dos.feature')
74
+ f.should have(5).scenarios
75
+ end
71
76
  end
72
77
  end
73
78
  end
@@ -0,0 +1,24 @@
1
+ Feature: Search
2
+ In order to learn cucumber
3
+ As an engineer
4
+ I want to run some simple tests
5
+
6
+ Scenario: 1) Reverse a String
7
+ Given a string "abc"
8
+ When the string is reversed
9
+ Then the string should be "cba"
10
+
11
+ |input |output|
12
+ |a |a |
13
+ |ab |ba |
14
+
15
+ Scenario: 2) Upcase a String
16
+ Given a string "abc"
17
+ When the string is upcased
18
+ Then the string should be "ABC"
19
+
20
+ Scenario: 3) Combining 2 Methods
21
+ Given a string "abc"
22
+ When the string is upcased
23
+ And the string is reversed
24
+ Then the string should be "CBA"
@@ -5,13 +5,7 @@ require 'spec'
5
5
  $:.unshift(File.dirname(__FILE__) + '/../lib')
6
6
  require 'cucumber'
7
7
  require 'cucumber/treetop_parser/feature_en'
8
-
9
- # Prevent CLI's exit hook from running
10
- class Cucumber::CLI
11
- def self.execute_called?
12
- true
13
- end
14
- end
8
+ Cucumber.load_language('en')
15
9
 
16
10
  # Open up the tree classes a little for easier inspection.
17
11
  module Cucumber
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-01 00:00:00 +02:00
12
+ date: 2008-10-05 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -109,6 +109,8 @@ files:
109
109
  - examples/danish_calculator/features/steps/kalkulator_steps.rb
110
110
  - examples/danish_calculator/features/summering.feature
111
111
  - examples/danish_calculator/lib/kalkulator.rb
112
+ - examples/dos_line_endings/Rakefile
113
+ - examples/dos_line_endings/features/dos_line_endings.feature
112
114
  - examples/estonian_calculator/Rakefile
113
115
  - examples/estonian_calculator/features/kalkulaator_steps.rb
114
116
  - examples/estonian_calculator/features/liitmine.feature
@@ -218,6 +220,7 @@ files:
218
220
  - spec/cucumber/sell_cucumbers.feature
219
221
  - spec/cucumber/step_mother_spec.rb
220
222
  - spec/cucumber/tree/scenario_spec.rb
223
+ - spec/cucumber/tree/step_spec.rb
221
224
  - spec/cucumber/treetop_parser/empty_feature.feature
222
225
  - spec/cucumber/treetop_parser/empty_scenario.feature
223
226
  - spec/cucumber/treetop_parser/feature_parser_spec.rb
@@ -225,6 +228,7 @@ files:
225
228
  - spec/cucumber/treetop_parser/given_scenario.feature
226
229
  - spec/cucumber/treetop_parser/multiple_tables.feature
227
230
  - spec/cucumber/treetop_parser/spaces.feature
231
+ - spec/cucumber/treetop_parser/test_dos.feature
228
232
  - spec/cucumber/treetop_parser/with_comments.feature
229
233
  - spec/spec.opts
230
234
  - spec/spec_helper.rb