elight-cucumber 0.1.9

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 (186) hide show
  1. data/History.txt +150 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +186 -0
  4. data/README.txt +41 -0
  5. data/Rakefile +5 -0
  6. data/TODO.txt +26 -0
  7. data/bin/cucumber +4 -0
  8. data/config/hoe.rb +69 -0
  9. data/config/requirements.rb +15 -0
  10. data/cucumber.yml +1 -0
  11. data/examples/calculator/README.txt +5 -0
  12. data/examples/calculator/Rakefile +5 -0
  13. data/examples/calculator/features/addition.feature +17 -0
  14. data/examples/calculator/features/division.feature +10 -0
  15. data/examples/calculator/features/steps/calculator_steps.rb +31 -0
  16. data/examples/calculator/lib/calculator.rb +16 -0
  17. data/examples/calculator_ruby_features/Rakefile +6 -0
  18. data/examples/calculator_ruby_features/features/addition.rb +23 -0
  19. data/examples/calculator_ruby_features/features/steps/calculator_steps.rb +43 -0
  20. data/examples/calculatrice_francaise_avec_soit_scenario/Rakefile +6 -0
  21. data/examples/calculatrice_francaise_avec_soit_scenario/features/addition.feature +13 -0
  22. data/examples/calculatrice_francaise_avec_soit_scenario/features/calculatrice_steps.rb +31 -0
  23. data/examples/chinese_simplified_calculator/Rakefile +6 -0
  24. data/examples/chinese_simplified_calculator/features/addition.feature +17 -0
  25. data/examples/chinese_simplified_calculator/features/steps/calculator_steps.rb +24 -0
  26. data/examples/chinese_simplified_calculator/lib/calculator.rb +10 -0
  27. data/examples/cs/README.textile +22 -0
  28. data/examples/cs/Rakefile +12 -0
  29. data/examples/cs/features/hello.feature +11 -0
  30. data/examples/cs/features/steps/hello_steps.rb +25 -0
  31. data/examples/cs/features/steps/tree_steps.rb +14 -0
  32. data/examples/cs/features/tree.feature +9 -0
  33. data/examples/cs/src/Hello.cs +18 -0
  34. data/examples/danish_calculator/Rakefile +6 -0
  35. data/examples/danish_calculator/features/steps/kalkulator_steps.rb +22 -0
  36. data/examples/danish_calculator/features/summering.feature +17 -0
  37. data/examples/danish_calculator/lib/kalkulator.rb +11 -0
  38. data/examples/dos_line_endings/Rakefile +6 -0
  39. data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
  40. data/examples/estonian_calculator/Rakefile +6 -0
  41. data/examples/estonian_calculator/features/kalkulaator_steps.rb +35 -0
  42. data/examples/estonian_calculator/features/liitmine.feature +16 -0
  43. data/examples/japanese_calculator/README.txt +5 -0
  44. data/examples/japanese_calculator/Rakefile +6 -0
  45. data/examples/japanese_calculator/features/addition.feature +17 -0
  46. data/examples/japanese_calculator/features/division.feature +10 -0
  47. data/examples/japanese_calculator/features/steps/calculator_steps.rb +30 -0
  48. data/examples/japanese_calculator/lib/calculator.rb +16 -0
  49. data/examples/java/README.textile +22 -0
  50. data/examples/java/Rakefile +12 -0
  51. data/examples/java/features/hello.feature +11 -0
  52. data/examples/java/features/steps/hello_steps.rb +25 -0
  53. data/examples/java/features/steps/tree_steps.rb +14 -0
  54. data/examples/java/features/tree.feature +9 -0
  55. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  56. data/examples/norwegian_calculator/Rakefile +6 -0
  57. data/examples/norwegian_calculator/features/steps/kalkulator_steps.rb +22 -0
  58. data/examples/norwegian_calculator/features/summering.feature +17 -0
  59. data/examples/norwegian_calculator/lib/kalkulator.rb +11 -0
  60. data/examples/portuguese_calculator/Rakefile +6 -0
  61. data/examples/portuguese_calculator/features/adicao.feature +10 -0
  62. data/examples/portuguese_calculator/features/calculadora_steps.rb +31 -0
  63. data/examples/selenium/Rakefile +6 -0
  64. data/examples/selenium/features/search.feature +9 -0
  65. data/examples/selenium/features/steps/stories_steps.rb +41 -0
  66. data/examples/spanish_calculator/Rakefile +6 -0
  67. data/examples/spanish_calculator/features/adicion.feature +17 -0
  68. data/examples/spanish_calculator/features/steps/calculador_steps.rb +22 -0
  69. data/examples/swedish_calculator/Rakefile +5 -0
  70. data/examples/swedish_calculator/features/steps/kalkulator_steps.rb +22 -0
  71. data/examples/swedish_calculator/features/summering.feature +17 -0
  72. data/examples/swedish_calculator/lib/kalkulator.rb +11 -0
  73. data/examples/tickets/Rakefile +11 -0
  74. data/examples/tickets/cucumber.yml +2 -0
  75. data/examples/tickets/features/steps/tickets_steps.rb +32 -0
  76. data/examples/tickets/features/tickets.feature +22 -0
  77. data/examples/watir/Rakefile +6 -0
  78. data/examples/watir/features/search.feature +9 -0
  79. data/examples/watir/features/steps/stories_steps.rb +51 -0
  80. data/features/see_features.feature +8 -0
  81. data/features/steps/features_steps.rb +9 -0
  82. data/gem_tasks/deployment.rake +34 -0
  83. data/gem_tasks/environment.rake +7 -0
  84. data/gem_tasks/features.rake +6 -0
  85. data/gem_tasks/fix_cr_lf.rake +10 -0
  86. data/gem_tasks/flog.rake +4 -0
  87. data/gem_tasks/gemspec.rake +6 -0
  88. data/gem_tasks/rspec.rake +21 -0
  89. data/gem_tasks/treetop.rake +49 -0
  90. data/lib/cucumber.rb +35 -0
  91. data/lib/cucumber/cli.rb +191 -0
  92. data/lib/cucumber/core_ext/proc.rb +55 -0
  93. data/lib/cucumber/core_ext/string.rb +22 -0
  94. data/lib/cucumber/executor.rb +143 -0
  95. data/lib/cucumber/formatters.rb +1 -0
  96. data/lib/cucumber/formatters/ansicolor.rb +112 -0
  97. data/lib/cucumber/formatters/cucumber.css +132 -0
  98. data/lib/cucumber/formatters/cucumber.js +11 -0
  99. data/lib/cucumber/formatters/html_formatter.rb +128 -0
  100. data/lib/cucumber/formatters/jquery.js +32 -0
  101. data/lib/cucumber/formatters/pretty_formatter.rb +211 -0
  102. data/lib/cucumber/formatters/profile_formatter.rb +92 -0
  103. data/lib/cucumber/formatters/progress_formatter.rb +51 -0
  104. data/lib/cucumber/languages.yml +142 -0
  105. data/lib/cucumber/model.rb +1 -0
  106. data/lib/cucumber/model/table.rb +28 -0
  107. data/lib/cucumber/rails/rspec.rb +12 -0
  108. data/lib/cucumber/rails/world.rb +73 -0
  109. data/lib/cucumber/rake/task.rb +75 -0
  110. data/lib/cucumber/step_methods.rb +49 -0
  111. data/lib/cucumber/step_mother.rb +83 -0
  112. data/lib/cucumber/tree.rb +18 -0
  113. data/lib/cucumber/tree/feature.rb +60 -0
  114. data/lib/cucumber/tree/features.rb +21 -0
  115. data/lib/cucumber/tree/given_scenario.rb +13 -0
  116. data/lib/cucumber/tree/scenario.rb +150 -0
  117. data/lib/cucumber/tree/step.rb +133 -0
  118. data/lib/cucumber/tree/table.rb +26 -0
  119. data/lib/cucumber/tree/top_down_visitor.rb +23 -0
  120. data/lib/cucumber/treetop_parser/feature.treetop.erb +201 -0
  121. data/lib/cucumber/treetop_parser/feature_da.rb +1593 -0
  122. data/lib/cucumber/treetop_parser/feature_de.rb +1593 -0
  123. data/lib/cucumber/treetop_parser/feature_en-tx.rb +1593 -0
  124. data/lib/cucumber/treetop_parser/feature_en.rb +1593 -0
  125. data/lib/cucumber/treetop_parser/feature_es.rb +1593 -0
  126. data/lib/cucumber/treetop_parser/feature_et.rb +1593 -0
  127. data/lib/cucumber/treetop_parser/feature_fr.rb +1593 -0
  128. data/lib/cucumber/treetop_parser/feature_ja.rb +1593 -0
  129. data/lib/cucumber/treetop_parser/feature_nl.rb +1593 -0
  130. data/lib/cucumber/treetop_parser/feature_no.rb +1593 -0
  131. data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
  132. data/lib/cucumber/treetop_parser/feature_pt.rb +1593 -0
  133. data/lib/cucumber/treetop_parser/feature_ru.rb +1593 -0
  134. data/lib/cucumber/treetop_parser/feature_se.rb +1593 -0
  135. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1593 -0
  136. data/lib/cucumber/version.rb +9 -0
  137. data/rails_generators/cucumber/cucumber_generator.rb +29 -0
  138. data/rails_generators/cucumber/templates/common_webrat.rb +42 -0
  139. data/rails_generators/cucumber/templates/cucumber +2 -0
  140. data/rails_generators/cucumber/templates/cucumber.rake +12 -0
  141. data/rails_generators/cucumber/templates/cucumber.yml +1 -0
  142. data/rails_generators/cucumber/templates/env.rb +8 -0
  143. data/rails_generators/feature/feature_generator.rb +17 -0
  144. data/rails_generators/feature/templates/feature.erb +28 -0
  145. data/rails_generators/feature/templates/steps.erb +22 -0
  146. data/script/console +10 -0
  147. data/script/console.cmd +1 -0
  148. data/script/destroy +14 -0
  149. data/script/destroy.cmd +1 -0
  150. data/script/generate +14 -0
  151. data/script/generate.cmd +1 -0
  152. data/script/txt2html +74 -0
  153. data/script/txt2html.cmd +1 -0
  154. data/setup.rb +1585 -0
  155. data/spec/cucumber/cli_spec.rb +56 -0
  156. data/spec/cucumber/core_ext/proc_spec.rb +45 -0
  157. data/spec/cucumber/core_ext/string_spec.rb +34 -0
  158. data/spec/cucumber/executor_spec.rb +130 -0
  159. data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
  160. data/spec/cucumber/formatters/features.html +269 -0
  161. data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
  162. data/spec/cucumber/formatters/pretty_formatter_spec.rb +111 -0
  163. data/spec/cucumber/formatters/profile_formatter_spec.rb +193 -0
  164. data/spec/cucumber/formatters/progress_formatter_spec.rb +45 -0
  165. data/spec/cucumber/model/table_spec.rb +20 -0
  166. data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
  167. data/spec/cucumber/rails/stubs/test_help.rb +1 -0
  168. data/spec/cucumber/rails/world_spec.rb +11 -0
  169. data/spec/cucumber/sell_cucumbers.feature +9 -0
  170. data/spec/cucumber/step_mother_spec.rb +53 -0
  171. data/spec/cucumber/tree/feature_spec.rb +12 -0
  172. data/spec/cucumber/tree/scenario_spec.rb +37 -0
  173. data/spec/cucumber/tree/step_spec.rb +31 -0
  174. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  175. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  176. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +96 -0
  177. data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
  178. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  179. data/spec/cucumber/treetop_parser/multiline_steps.feature +13 -0
  180. data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
  181. data/spec/cucumber/treetop_parser/spaces.feature +10 -0
  182. data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
  183. data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
  184. data/spec/spec.opts +2 -0
  185. data/spec/spec_helper.rb +19 -0
  186. metadata +288 -0
@@ -0,0 +1,74 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'stringio'
3
+ require 'cucumber/tree/top_down_visitor'
4
+
5
+ module Cucumber
6
+ module Formatters
7
+ class MiniExecutor < Cucumber::Tree::TopDownVisitor
8
+ def initialize(f)
9
+ @f = f
10
+ end
11
+
12
+ def visit_step(step)
13
+ if step.regexp == //
14
+ # Just make sure there are some params so we can get <span>s
15
+ proc = lambda do |_|
16
+ case(step.id % 3)
17
+ when 0
18
+ raise Pending
19
+ when 1
20
+ raise "This one failed"
21
+ end
22
+ end
23
+ proc.extend(CoreExt::CallIn)
24
+ proc.name = "WHATEVER"
25
+ step.attach(/(\w+).*/, proc, ['xxx'])
26
+ o = Object.new
27
+ step.execute_in(o) rescue nil
28
+ else
29
+ @f.step_executed(step)
30
+ end
31
+ end
32
+ end
33
+
34
+ describe HtmlFormatter do
35
+ SIMPLE_DIR = File.dirname(__FILE__) + '/../../../examples/simple'
36
+
37
+ before do
38
+ p = Cucumber::TreetopParser::FeatureParser.new
39
+ @features = Tree::Features.new
40
+ Dir["#{SIMPLE_DIR}/*.feature"].each do |f|
41
+ @features << p.parse_feature(f)
42
+ end
43
+ @io = StringIO.new
44
+ step_mother = mock('step mother')
45
+ @formatter = HtmlFormatter.new(@io, step_mother)
46
+ @me = MiniExecutor.new(@formatter)
47
+ end
48
+
49
+ xit "should render HTML" do
50
+ @me.visit_features(@features) # set regexp+proc+args and execute
51
+ @formatter.visit_features(@features)
52
+ @me.visit_features(@features) # output result of execution
53
+ @formatter.dump
54
+ expected_html = File.dirname(__FILE__) + '/features.html'
55
+ #File.open(expected_html, 'w') {|io| io.write(@io.string)}
56
+ @io.string.should eql(IO.read(expected_html))
57
+ end
58
+
59
+ it "should render FIT table headers" do
60
+ scenario = mock('scenario', :name => 'test', :accept => nil)
61
+ row_scenario = mock('row scenario', :name => 'test', :accept => nil)
62
+ scenario.stub!(:table_header).and_return(['test', 'fit', 'headers'])
63
+
64
+ @formatter.visit_regular_scenario(scenario)
65
+ @formatter.visit_row_scenario(row_scenario)
66
+
67
+ ['test', 'fit' ,'headers'].each do |column_header|
68
+ @io.string.should include(column_header)
69
+ end
70
+ end
71
+
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,111 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Cucumber
4
+ module Formatters
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_scenario(stubs={})
17
+ stub('scenario', {
18
+ :name => 'test',
19
+ :row? => false }.merge(stubs))
20
+ end
21
+
22
+ def mock_feature(stubs={})
23
+ stub("feature", stubs)
24
+ end
25
+
26
+ def mock_error(stubs={})
27
+ stub('error', {
28
+ :message => 'failed',
29
+ :backtrace => 'example backtrace'}.merge(stubs))
30
+ end
31
+
32
+ def mock_proc
33
+ stub(Proc, :to_comment_line => '# steps/example_steps.rb:11')
34
+ end
35
+
36
+ it "should print step file and line when passed" do
37
+ io = StringIO.new
38
+ formatter = PrettyFormatter.new io, StepMother.new
39
+ step = stub('step',
40
+ :error => nil, :row? => false, :keyword => 'Given', :format => 'formatted yes'
41
+ )
42
+ formatter.step_passed(step, nil, nil)
43
+ io.string.should == " Given formatted yes\n"
44
+ end
45
+
46
+ describe "show source option true" do
47
+
48
+ before(:each) do
49
+ @io = StringIO.new
50
+ step_mother = mock('step_mother')
51
+ @formatter = PrettyFormatter.new @io, step_mother, :source => true
52
+ end
53
+
54
+ %w{passed failed skipped}.each do |result|
55
+ it "should display step source for #{result} step" do
56
+ @formatter.send("step_#{result}".to_sym, mock_step(:regexp_args_proc => [nil, nil, mock_proc], :error => StandardError.new, :padding_length => 2), nil, nil)
57
+
58
+ @io.string.should include("Given formatted yes # steps/example_steps.rb:11")
59
+ end
60
+ end
61
+
62
+ it "should display feature file and line for pending step" do
63
+ @formatter.step_pending(mock_step(:name => 'test', :file => 'features/example.feature', :line => 5, :padding_length => 2), nil, nil)
64
+
65
+ @io.string.should include("Given test # features/example.feature:5")
66
+ end
67
+
68
+ it "should display file and line for scenario" do
69
+ @formatter.scenario_executing(mock_scenario(:name => "title", :file => 'features/example.feature', :line => 2 , :padding_length => 2))
70
+
71
+ @io.string.should include("Scenario: title # features/example.feature:2")
72
+ end
73
+
74
+ it "should display file for feature" do
75
+ @formatter.visit_feature(mock_feature(:file => 'features/example.feature', :padding_length => 2))
76
+ @formatter.header_executing("Feature: test\n In order to ...\n As a ...\n I want to ...\n")
77
+
78
+ @io.string.should include("Feature: test # features/example.feature\n")
79
+ @io.string.should include("In order to ...\n")
80
+ @io.string.should include("As a ...\n")
81
+ @io.string.should include("I want to ...\n")
82
+ end
83
+
84
+ it "should align step comments" do
85
+ step_1 = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :format => "1", :padding_length => 10)
86
+ step_4 = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :format => "4444", :padding_length => 7)
87
+ step_9 = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :format => "999999999", :padding_length => 2)
88
+
89
+ @formatter.step_passed(step_1, nil, nil)
90
+ @formatter.step_passed(step_4, nil, nil)
91
+ @formatter.step_passed(step_9, nil, nil)
92
+
93
+ @io.string.should include("Given 1 # steps/example_steps.rb:11")
94
+ @io.string.should include("Given 4444 # steps/example_steps.rb:11")
95
+ @io.string.should include("Given 999999999 # steps/example_steps.rb:11")
96
+ end
97
+
98
+ it "should align step comments with respect to their scenario's comment" do
99
+ step = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :error => StandardError.new, :padding_length => 6)
100
+
101
+ @formatter.scenario_executing(mock_scenario(:name => "very long title", :file => 'features/example.feature', :line => 5, :steps => [step], :padding_length => 2))
102
+ @formatter.step_passed(step, nil, nil)
103
+
104
+ @io.string.should include("Scenario: very long title # features/example.feature:5")
105
+ @io.string.should include(" Given formatted yes # steps/example_steps.rb:11")
106
+ end
107
+
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,193 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Cucumber
4
+ module Formatters
5
+ describe ProfileFormatter do
6
+ attr_reader :io, :formatter
7
+
8
+ def mock_proc(stubs={})
9
+ stub(Proc, {:to_comment_line => '# steps/example_steps.rb:11'}.merge(stubs))
10
+ end
11
+
12
+ def mock_step(stubs={})
13
+ stub('step', {:keyword => 'Given',
14
+ :actual_keyword => 'Given',
15
+ :format => 'test',
16
+ :row? => false,
17
+ :file => 'test.feature',
18
+ :line => 5,
19
+ :regexp_args_proc => [nil, nil, mock_proc]}.merge(stubs))
20
+ end
21
+
22
+ before(:each) do
23
+ @io = StringIO.new
24
+ step_mother = stub('step_mother')
25
+ @formatter = ProfileFormatter.new(io, step_mother)
26
+ end
27
+
28
+ it "should print a heading" do
29
+ formatter.visit_features(nil)
30
+
31
+ io.string.should eql("Profiling enabled.\n")
32
+ end
33
+
34
+ it "should record the current time when starting a new step" do
35
+ now = Time.now
36
+ Time.stub!(:now).and_return(now)
37
+ formatter.step_executing('should foo', nil, nil)
38
+
39
+ formatter.instance_variable_get("@step_time").should == now
40
+ end
41
+
42
+ describe "grouping recorded passed steps" do
43
+
44
+ before(:each) do
45
+ now = Time.now
46
+ formatter.instance_variable_set("@step_time", now)
47
+ Time.stub!(:now).and_return(now, now)
48
+ end
49
+
50
+ it "should group by regular expressions and actual keyword" do
51
+ step_1 = mock_step(:actual_keyword => 'Given')
52
+ step_2 = mock_step(:actual_keyword => 'Given')
53
+
54
+ formatter.step_passed(step_1, /nihon/, nil)
55
+ formatter.step_passed(step_2, /ichiban/, nil)
56
+
57
+ step_times = formatter.instance_variable_get("@step_times")
58
+
59
+ step_times.has_key?('Given /nihon/').should be_true
60
+ step_times.has_key?('Given /ichiban/').should be_true
61
+ end
62
+
63
+ it "should use a previous step's keyword when recording row steps" do
64
+ step = mock_step(:actual_keyword => 'Given')
65
+ step_row = mock_step(:row? => true)
66
+
67
+ formatter.step_passed(step, /nihon/, [])
68
+ formatter.step_passed(step_row, /nihon/, [])
69
+
70
+ step_times = formatter.instance_variable_get("@step_times")
71
+
72
+ step_times['Given /nihon/'].length.should == 2
73
+ end
74
+
75
+ end
76
+
77
+ it "should correctly record a passed step" do
78
+ formatter.step_executing(nil, nil, nil)
79
+ formatter.step_passed(mock_step(:format => 'she doth teach the torches to burn bright', :actual_keyword => 'Given'), nil, nil)
80
+ formatter.dump
81
+
82
+ io.string.should include('Given she doth teach the torches to burn bright')
83
+ end
84
+
85
+ it "should correctly record a passed step row" do
86
+ formatter.step_executing(nil, nil, nil)
87
+ formatter.step_passed(mock_step(:row? => true), /example/, ['fitty'])
88
+ formatter.dump
89
+
90
+ io.string.should include('fitty')
91
+ end
92
+
93
+ it "should calculate the mean step execution time" do
94
+ now = Time.now
95
+ Time.stub!(:now).and_return(now, now+5, now, now+1)
96
+
97
+ 2.times do
98
+ formatter.step_executing(mock_step, nil, nil)
99
+ formatter.step_passed(mock_step, nil, nil)
100
+ end
101
+
102
+ formatter.dump
103
+
104
+ io.string.should include('3.0000000')
105
+ end
106
+
107
+ it "should display file and line comment for step invocation" do
108
+ step = mock_step(:format => 'test', :actual_keyword => 'Given', :file => 'test.feature', :line => 5)
109
+
110
+ formatter.step_executing(step, nil, nil)
111
+ formatter.step_passed(step, nil, nil)
112
+ formatter.dump
113
+
114
+ @io.string.should include("# test.feature:5")
115
+ end
116
+
117
+ it "should display file and line comment for step definition" do
118
+ step = mock_step(:format => 'test', :actual_keyword => 'Given',
119
+ :regexp_args_proc => [/test/, nil, mock_proc(:to_comment_line => '# steps/example_steps.rb:11')])
120
+
121
+ formatter.step_executing(step, nil, nil)
122
+ formatter.step_passed(step, nil, nil)
123
+ formatter.dump
124
+
125
+ @io.string.should include("# steps/example_steps.rb:11")
126
+ end
127
+
128
+ it "should show the performance times of the step invocations for a step definition" do
129
+ now = Time.now
130
+ Time.stub!(:now).and_return(now, now+5, now, now+1)
131
+
132
+ step = mock_step(:format => 'step invocation', :actual_keyword => 'Given')
133
+
134
+ 2.times do
135
+ formatter.step_executing(step, /example/, nil)
136
+ formatter.step_passed(step, /example/, nil)
137
+ end
138
+
139
+ formatter.dump
140
+
141
+ io.string.should include("3.0000000 Given /example/")
142
+ io.string.should include("5.0000000 Given step invocation")
143
+ io.string.should include("1.0000000 Given step invocation")
144
+ end
145
+
146
+ it "should sort the step invocations in descending order" do
147
+ now = Time.now
148
+ Time.stub!(:now).and_return(now, now+1, now, now+5)
149
+
150
+ step = mock_step(:format => 'step invocation', :actual_keyword => 'Given')
151
+
152
+ 2.times do
153
+ formatter.step_executing(step, /example 1/, nil)
154
+ formatter.step_passed(step, /example 1/, nil)
155
+ end
156
+
157
+ formatter.dump
158
+ io_string_lines = io.string.split("\n")
159
+
160
+ io_string_lines.at(-2).should include('5.0000000')
161
+ io_string_lines.at(-1).should include('1.0000000')
162
+ end
163
+
164
+ it "should print the top average 10 step results" do
165
+ formatter.instance_variable_set("@step_time", Time.now)
166
+
167
+ 11.times do |test_number|
168
+ step_regexp = Regexp.new "unique_test_#{test_number}"
169
+ formatter.step_passed(mock_step(:format => 'test', :actual_keyword => 'Given',
170
+ :regexp_args_proc => [step_regexp, nil, mock_proc]), step_regexp, nil)
171
+ end
172
+
173
+ formatter.dump
174
+
175
+ io.string.scan(/unique_test_\d+/).length.should == 10
176
+ end
177
+
178
+ it "should print the top 5 step invocations for step definition" do
179
+ formatter.instance_variable_set("@step_time", Time.now)
180
+ step_definition_put = 1
181
+
182
+ 10.times do |test_number|
183
+ formatter.step_passed(mock_step(:format => 'please invocate me', :actual_keyword => 'Given'), nil, nil)
184
+ end
185
+
186
+ formatter.dump
187
+
188
+ io.string.scan(/please invocate me/).length.should == 5
189
+ end
190
+
191
+ end
192
+ end
193
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Cucumber
4
+ module Formatters
5
+ describe ProgressFormatter do
6
+ it "should print . when passed" do
7
+ io = StringIO.new
8
+ formatter = ProgressFormatter.new io
9
+ step = stub('step',
10
+ :error => nil
11
+ )
12
+ formatter.step_passed(step,nil,nil)
13
+ io.string.should =~ /^\.$/
14
+ end
15
+
16
+ it "should print F when failed" do
17
+ io = StringIO.new
18
+ formatter = ProgressFormatter.new io
19
+ step = stub('step',
20
+ :error => StandardError.new
21
+ )
22
+ formatter.step_failed(step,nil,nil)
23
+ io.string.should =~ /^\F$/
24
+ end
25
+
26
+ it "should print P when pending" do
27
+ io = StringIO.new
28
+ formatter = ProgressFormatter.new io
29
+ step = stub('step',
30
+ :error => Pending.new,
31
+ :scenario => mock('scenario')
32
+ )
33
+ formatter.step_pending(step,nil,nil)
34
+ io.string.should =~ /^\P$/
35
+ end
36
+
37
+ it "should print _ when skipped" do
38
+ io = StringIO.new
39
+ formatter = ProgressFormatter.new io
40
+ formatter.step_skipped(nil,nil,nil)
41
+ io.string.should =~ /^_$/
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Cucumber
4
+ module Model
5
+ describe Table do
6
+ it "should convert into hash-array" do
7
+ raw = [
8
+ %w{name gender},
9
+ %w{aslak male},
10
+ %w{patty female},
11
+ ]
12
+ ha = Table.new(raw).hashes
13
+ ha.should == [
14
+ {'name' => 'aslak', 'gender' => 'male'},
15
+ {'name' => 'patty', 'gender' => 'female'}
16
+ ]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # Define some stubs to fake Rails...
2
+ module ActiveRecord
3
+ class Base
4
+ end
5
+ end
6
+
7
+ module ActionController
8
+ class Base
9
+ end
10
+ class IntegrationTest
11
+ def self.use_transactional_fixtures=(x)
12
+ end
13
+ end
14
+ end
15
+
16
+ module Dispatcher
17
+ end