jeffrafter-cucumber 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. data/History.txt +262 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +241 -0
  4. data/README.txt +41 -0
  5. data/Rakefile +8 -0
  6. data/TODO.txt +26 -0
  7. data/bin/cucumber +6 -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_ruby_features/Rakefile +6 -0
  12. data/examples/calculator_ruby_features/features/addition.rb +23 -0
  13. data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +43 -0
  14. data/examples/cs/README.textile +22 -0
  15. data/examples/cs/Rakefile +12 -0
  16. data/examples/cs/features/hello.feature +11 -0
  17. data/examples/cs/features/step_definitons/hello_steps.rb +25 -0
  18. data/examples/cs/features/step_definitons/tree_steps.rb +14 -0
  19. data/examples/cs/features/tree.feature +9 -0
  20. data/examples/cs/src/Hello.cs +18 -0
  21. data/examples/dos_line_endings/Rakefile +6 -0
  22. data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
  23. data/examples/i18n/README.textile +18 -0
  24. data/examples/i18n/Rakefile +16 -0
  25. data/examples/i18n/ar/Rakefile +6 -0
  26. data/examples/i18n/ar/features/addition.feature +17 -0
  27. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +32 -0
  28. data/examples/i18n/ar/lib/calculator.rb +10 -0
  29. data/examples/i18n/da/Rakefile +6 -0
  30. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +22 -0
  31. data/examples/i18n/da/features/summering.feature +17 -0
  32. data/examples/i18n/da/lib/kalkulator.rb +11 -0
  33. data/examples/i18n/de/Rakefile +6 -0
  34. data/examples/i18n/de/features/addition.feature +17 -0
  35. data/examples/i18n/de/features/division.feature +10 -0
  36. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +30 -0
  37. data/examples/i18n/de/lib/calculator.rb +14 -0
  38. data/examples/i18n/en/Rakefile +6 -0
  39. data/examples/i18n/en/features/addition.feature +17 -0
  40. data/examples/i18n/en/features/division.feature +10 -0
  41. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +31 -0
  42. data/examples/i18n/en/lib/calculator.rb +14 -0
  43. data/examples/i18n/es/Rakefile +6 -0
  44. data/examples/i18n/es/features/adicion.feature +17 -0
  45. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +22 -0
  46. data/examples/i18n/es/lib/calculador.rb +11 -0
  47. data/examples/i18n/et/Rakefile +6 -0
  48. data/examples/i18n/et/features/liitmine.feature +17 -0
  49. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +26 -0
  50. data/examples/i18n/et/lib/kalkulaator.rb +10 -0
  51. data/examples/i18n/fr/Rakefile +6 -0
  52. data/examples/i18n/fr/features/addition.feature +13 -0
  53. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +22 -0
  54. data/examples/i18n/fr/lib/calculatrice.rb +10 -0
  55. data/examples/i18n/id/Rakefile +6 -0
  56. data/examples/i18n/id/features/addition.feature +17 -0
  57. data/examples/i18n/id/features/division.feature +10 -0
  58. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +31 -0
  59. data/examples/i18n/id/lib/calculator.rb +14 -0
  60. data/examples/i18n/it/Rakefile +6 -0
  61. data/examples/i18n/it/features/somma.feature +10 -0
  62. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +22 -0
  63. data/examples/i18n/it/lib/calcolatrice.rb +11 -0
  64. data/examples/i18n/ja/README.txt +5 -0
  65. data/examples/i18n/ja/Rakefile +6 -0
  66. data/examples/i18n/ja/features/addition.feature +17 -0
  67. data/examples/i18n/ja/features/division.feature +10 -0
  68. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +30 -0
  69. data/examples/i18n/ja/lib/calculator.rb +14 -0
  70. data/examples/i18n/lt/Rakefile +6 -0
  71. data/examples/i18n/lt/features/addition.feature +17 -0
  72. data/examples/i18n/lt/features/division.feature +10 -0
  73. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +31 -0
  74. data/examples/i18n/lt/lib/calculator.rb +14 -0
  75. data/examples/i18n/no/Rakefile +6 -0
  76. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +22 -0
  77. data/examples/i18n/no/features/summering.feature +17 -0
  78. data/examples/i18n/no/lib/kalkulator.rb +11 -0
  79. data/examples/i18n/pt/Rakefile +6 -0
  80. data/examples/i18n/pt/features/adicao.feature +10 -0
  81. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +22 -0
  82. data/examples/i18n/pt/lib/calculadora.rb +10 -0
  83. data/examples/i18n/ro/Rakefile +6 -0
  84. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +22 -0
  85. data/examples/i18n/ro/features/suma.feature +10 -0
  86. data/examples/i18n/ro/lib/calculator.rb +11 -0
  87. data/examples/i18n/se/Rakefile +6 -0
  88. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +22 -0
  89. data/examples/i18n/se/features/summering.feature +17 -0
  90. data/examples/i18n/se/lib/kalkulator.rb +11 -0
  91. data/examples/i18n/zh-CN/Rakefile +6 -0
  92. data/examples/i18n/zh-CN/features/addition.feature +17 -0
  93. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +24 -0
  94. data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
  95. data/examples/java/README.textile +22 -0
  96. data/examples/java/Rakefile +12 -0
  97. data/examples/java/features/hello.feature +11 -0
  98. data/examples/java/features/step_definitons/hello_steps.rb +25 -0
  99. data/examples/java/features/step_definitons/tree_steps.rb +14 -0
  100. data/examples/java/features/tree.feature +9 -0
  101. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  102. data/examples/selenium/Rakefile +6 -0
  103. data/examples/selenium/features/search.feature +9 -0
  104. data/examples/selenium/features/step_definitons/stories_steps.rb +41 -0
  105. data/examples/test_unit/Rakefile +6 -0
  106. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +26 -0
  107. data/examples/test_unit/features/test_unit.feature +9 -0
  108. data/examples/tickets/Rakefile +11 -0
  109. data/examples/tickets/cucumber.yml +2 -0
  110. data/examples/tickets/features/step_definitons/tickets_steps.rb +32 -0
  111. data/examples/tickets/features/tickets.feature +24 -0
  112. data/examples/watir/Rakefile +6 -0
  113. data/examples/watir/features/search.feature +9 -0
  114. data/examples/watir/features/step_definitons/stories_steps.rb +51 -0
  115. data/features/see_features.feature +8 -0
  116. data/features/steps/features_steps.rb +9 -0
  117. data/gem_tasks/deployment.rake +34 -0
  118. data/gem_tasks/environment.rake +7 -0
  119. data/gem_tasks/features.rake +6 -0
  120. data/gem_tasks/fix_cr_lf.rake +10 -0
  121. data/gem_tasks/flog.rake +4 -0
  122. data/gem_tasks/gemspec.rake +6 -0
  123. data/gem_tasks/rspec.rake +35 -0
  124. data/gem_tasks/treetop.rake +41 -0
  125. data/lib/autotest/cucumber.rb +6 -0
  126. data/lib/autotest/cucumber_mixin.rb +109 -0
  127. data/lib/autotest/cucumber_rails.rb +6 -0
  128. data/lib/autotest/cucumber_rails_rspec.rb +6 -0
  129. data/lib/autotest/cucumber_rspec.rb +6 -0
  130. data/lib/autotest/discover.rb +9 -0
  131. data/lib/cucumber/broadcaster.rb +20 -0
  132. data/lib/cucumber/cli.rb +303 -0
  133. data/lib/cucumber/core_ext/proc.rb +69 -0
  134. data/lib/cucumber/core_ext/string.rb +28 -0
  135. data/lib/cucumber/executor.rb +190 -0
  136. data/lib/cucumber/formatters/ansicolor.rb +109 -0
  137. data/lib/cucumber/formatters/autotest_formatter.rb +23 -0
  138. data/lib/cucumber/formatters/cucumber.css +132 -0
  139. data/lib/cucumber/formatters/cucumber.js +11 -0
  140. data/lib/cucumber/formatters/html_formatter.rb +128 -0
  141. data/lib/cucumber/formatters/jquery.js +32 -0
  142. data/lib/cucumber/formatters/pretty_formatter.rb +234 -0
  143. data/lib/cucumber/formatters/profile_formatter.rb +92 -0
  144. data/lib/cucumber/formatters/progress_formatter.rb +58 -0
  145. data/lib/cucumber/formatters.rb +1 -0
  146. data/lib/cucumber/languages.yml +258 -0
  147. data/lib/cucumber/model/table.rb +28 -0
  148. data/lib/cucumber/model.rb +1 -0
  149. data/lib/cucumber/platform.rb +12 -0
  150. data/lib/cucumber/rails/rspec.rb +12 -0
  151. data/lib/cucumber/rails/world.rb +73 -0
  152. data/lib/cucumber/rake/task.rb +101 -0
  153. data/lib/cucumber/step_methods.rb +49 -0
  154. data/lib/cucumber/step_mother.rb +95 -0
  155. data/lib/cucumber/tree/feature.rb +63 -0
  156. data/lib/cucumber/tree/features.rb +21 -0
  157. data/lib/cucumber/tree/given_scenario.rb +13 -0
  158. data/lib/cucumber/tree/scenario.rb +174 -0
  159. data/lib/cucumber/tree/step.rb +134 -0
  160. data/lib/cucumber/tree/table.rb +26 -0
  161. data/lib/cucumber/tree/top_down_visitor.rb +23 -0
  162. data/lib/cucumber/tree.rb +18 -0
  163. data/lib/cucumber/treetop_parser/feature.treetop.erb +206 -0
  164. data/lib/cucumber/treetop_parser/feature_ar.rb +1591 -0
  165. data/lib/cucumber/treetop_parser/feature_cy.rb +1591 -0
  166. data/lib/cucumber/treetop_parser/feature_da.rb +1591 -0
  167. data/lib/cucumber/treetop_parser/feature_de.rb +1591 -0
  168. data/lib/cucumber/treetop_parser/feature_en-tx.rb +1591 -0
  169. data/lib/cucumber/treetop_parser/feature_en.rb +1591 -0
  170. data/lib/cucumber/treetop_parser/feature_es.rb +1591 -0
  171. data/lib/cucumber/treetop_parser/feature_et.rb +1591 -0
  172. data/lib/cucumber/treetop_parser/feature_fr.rb +1591 -0
  173. data/lib/cucumber/treetop_parser/feature_id.rb +1591 -0
  174. data/lib/cucumber/treetop_parser/feature_it.rb +1591 -0
  175. data/lib/cucumber/treetop_parser/feature_ja.rb +1591 -0
  176. data/lib/cucumber/treetop_parser/feature_lt.rb +1591 -0
  177. data/lib/cucumber/treetop_parser/feature_nl.rb +1591 -0
  178. data/lib/cucumber/treetop_parser/feature_no.rb +1591 -0
  179. data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
  180. data/lib/cucumber/treetop_parser/feature_pl.rb +1591 -0
  181. data/lib/cucumber/treetop_parser/feature_pt.rb +1591 -0
  182. data/lib/cucumber/treetop_parser/feature_ro.rb +1591 -0
  183. data/lib/cucumber/treetop_parser/feature_ro2.rb +1591 -0
  184. data/lib/cucumber/treetop_parser/feature_ru.rb +1591 -0
  185. data/lib/cucumber/treetop_parser/feature_se.rb +1591 -0
  186. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1591 -0
  187. data/lib/cucumber/version.rb +9 -0
  188. data/lib/cucumber.rb +38 -0
  189. data/rails_generators/cucumber/USAGE +11 -0
  190. data/rails_generators/cucumber/cucumber_generator.rb +30 -0
  191. data/rails_generators/cucumber/templates/cucumber +7 -0
  192. data/rails_generators/cucumber/templates/cucumber.rake +7 -0
  193. data/rails_generators/cucumber/templates/env.rb +8 -0
  194. data/rails_generators/cucumber/templates/webrat_steps.rb +95 -0
  195. data/rails_generators/feature/USAGE +12 -0
  196. data/rails_generators/feature/feature_generator.rb +16 -0
  197. data/rails_generators/feature/templates/feature.erb +28 -0
  198. data/rails_generators/feature/templates/steps.erb +22 -0
  199. data/script/console +10 -0
  200. data/script/console.cmd +1 -0
  201. data/script/destroy +14 -0
  202. data/script/destroy.cmd +1 -0
  203. data/script/generate +14 -0
  204. data/script/generate.cmd +1 -0
  205. data/script/txt2html +74 -0
  206. data/script/txt2html.cmd +1 -0
  207. data/setup.rb +1585 -0
  208. data/spec/cucumber/broadcaster_spec.rb +27 -0
  209. data/spec/cucumber/cli_spec.rb +412 -0
  210. data/spec/cucumber/core_ext/proc_spec.rb +45 -0
  211. data/spec/cucumber/core_ext/string_spec.rb +34 -0
  212. data/spec/cucumber/executor_spec.rb +298 -0
  213. data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
  214. data/spec/cucumber/formatters/autotest_formatter_spec.rb +26 -0
  215. data/spec/cucumber/formatters/features.html +269 -0
  216. data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
  217. data/spec/cucumber/formatters/pretty_formatter_spec.rb +204 -0
  218. data/spec/cucumber/formatters/profile_formatter_spec.rb +192 -0
  219. data/spec/cucumber/formatters/progress_formatter_spec.rb +65 -0
  220. data/spec/cucumber/model/table_spec.rb +20 -0
  221. data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
  222. data/spec/cucumber/rails/stubs/test_help.rb +1 -0
  223. data/spec/cucumber/rails/world_spec.rb +11 -0
  224. data/spec/cucumber/sell_cucumbers.feature +19 -0
  225. data/spec/cucumber/step_mother_spec.rb +74 -0
  226. data/spec/cucumber/tree/feature_spec.rb +43 -0
  227. data/spec/cucumber/tree/row_scenario_spec.rb +55 -0
  228. data/spec/cucumber/tree/scenario_spec.rb +76 -0
  229. data/spec/cucumber/tree/step_spec.rb +50 -0
  230. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  231. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  232. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +98 -0
  233. data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
  234. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  235. data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
  236. data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
  237. data/spec/cucumber/treetop_parser/spaces.feature +10 -0
  238. data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
  239. data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
  240. data/spec/spec.opts +2 -0
  241. data/spec/spec_helper.rb +20 -0
  242. metadata +335 -0
@@ -0,0 +1,190 @@
1
+ require 'cucumber/core_ext/proc'
2
+
3
+ module Cucumber
4
+ class Executor
5
+ attr_reader :failed
6
+ attr_accessor :formatters
7
+ attr_writer :scenario_names, :lines_for_features
8
+
9
+ def initialize(step_mother)
10
+ @world_procs = []
11
+ @before_scenario_procs = []
12
+ @after_scenario_procs = []
13
+ @after_step_procs = []
14
+ @step_mother = step_mother
15
+
16
+ @executed_scenarios = {}
17
+ @regular_scenario_cache = {}
18
+ end
19
+
20
+ def register_world_proc(&proc)
21
+ @world_procs << proc
22
+ end
23
+
24
+ def register_before_scenario_proc(&proc)
25
+ proc.extend(CoreExt::CallIn)
26
+ @before_scenario_procs << proc
27
+ end
28
+
29
+ def register_after_scenario_proc(&proc)
30
+ proc.extend(CoreExt::CallIn)
31
+ @after_scenario_procs << proc
32
+ end
33
+
34
+ def register_after_step_proc(&proc)
35
+ proc.extend(CoreExt::CallIn)
36
+ @after_step_procs << proc
37
+ end
38
+
39
+ def visit_features(features)
40
+ formatters.visit_features(features)
41
+ features.accept(self)
42
+ formatters.dump
43
+ end
44
+
45
+ def visit_feature(feature)
46
+ @feature_file = feature.file
47
+
48
+ if accept_feature?(feature)
49
+ formatters.feature_executing(feature)
50
+ feature.accept(self)
51
+ @executed_scenarios = {}
52
+ @regular_scenario_cache = {}
53
+ end
54
+ end
55
+
56
+ def visit_header(header)
57
+ formatters.header_executing(header)
58
+ end
59
+
60
+ def visit_row_scenario(scenario)
61
+ execute_scenario(@regular_scenario_cache[scenario.name]) if executing_unprepared_row_scenario?(scenario)
62
+ visit_scenario(scenario)
63
+ end
64
+
65
+ def visit_regular_scenario(scenario)
66
+ @regular_scenario_cache[scenario.name] = scenario
67
+ visit_scenario(scenario)
68
+ end
69
+
70
+ def visit_scenario(scenario)
71
+ if accept_scenario?(scenario)
72
+ @executed_scenarios[scenario.name] = true
73
+ execute_scenario(scenario)
74
+ end
75
+ end
76
+
77
+ def execute_scenario(scenario)
78
+ @error = nil
79
+ @pending = nil
80
+
81
+ @world = create_world
82
+ @world.extend(Spec::Matchers) if defined?(Spec::Matchers)
83
+ define_step_call_methods(@world)
84
+
85
+ formatters.scenario_executing(scenario)
86
+ @before_scenario_procs.each{|p| p.call_in(@world, *[])}
87
+ scenario.accept(self)
88
+ @after_scenario_procs.each{|p| p.call_in(@world, *[])}
89
+ formatters.scenario_executed(scenario)
90
+ end
91
+
92
+ def accept_scenario?(scenario)
93
+ scenario_at_specified_line?(scenario) &&
94
+ scenario_has_specified_name?(scenario)
95
+ end
96
+
97
+ def accept_feature?(feature)
98
+ feature.scenarios.any? { |s| accept_scenario?(s) }
99
+ end
100
+
101
+ def visit_row_step(step)
102
+ visit_step(step)
103
+ end
104
+
105
+ def visit_regular_step(step)
106
+ visit_step(step)
107
+ end
108
+
109
+ def visit_step(step)
110
+ unless @pending || @error
111
+ begin
112
+ regexp, args, proc = step.regexp_args_proc(@step_mother)
113
+ formatters.step_executing(step, regexp, args)
114
+ step.execute_in(@world, regexp, args, proc)
115
+ @after_step_procs.each{|p| p.call_in(@world, *[])}
116
+ formatters.step_passed(step, regexp, args)
117
+ rescue Pending
118
+ record_pending_step(step, regexp, args)
119
+ rescue => e
120
+ @failed = true
121
+ @error = step.error = e
122
+ formatters.step_failed(step, regexp, args)
123
+ end
124
+ else
125
+ begin
126
+ regexp, args, proc = step.regexp_args_proc(@step_mother)
127
+ step.execute_in(@world, regexp, args, proc)
128
+ formatters.step_skipped(step, regexp, args)
129
+ rescue Pending
130
+ record_pending_step(step, regexp, args)
131
+ rescue Exception
132
+ formatters.step_skipped(step, regexp, args)
133
+ end
134
+ end
135
+ end
136
+
137
+ def record_pending_step(step, regexp, args)
138
+ @pending = true
139
+ formatters.step_pending(step, regexp, args)
140
+ end
141
+
142
+ def define_step_call_methods(world)
143
+ world.instance_variable_set('@__executor', self)
144
+ world.instance_eval do
145
+ class << self
146
+ def run_step(name)
147
+ _, args, proc = @__executor.instance_variable_get(:@step_mother).regexp_args_proc(name)
148
+ proc.call_in(self, *args)
149
+ end
150
+
151
+ %w{given when then and but}.each do |keyword|
152
+ alias_method Cucumber.language[keyword], :run_step
153
+ end
154
+ end
155
+ end
156
+ end
157
+
158
+ def executing_unprepared_row_scenario?(scenario)
159
+ accept_scenario?(scenario) && !@executed_scenarios[scenario.name]
160
+ end
161
+
162
+ def scenario_at_specified_line?(scenario)
163
+ if lines_defined_for_current_feature?
164
+ @lines_for_features[@feature_file].inject(false) { |at_line, line| at_line || scenario.at_line?(line) }
165
+ else
166
+ true
167
+ end
168
+ end
169
+
170
+ def scenario_has_specified_name?(scenario)
171
+ if @scenario_names && !@scenario_names.empty?
172
+ @scenario_names.include?(scenario.name)
173
+ else
174
+ true
175
+ end
176
+ end
177
+
178
+ def lines_defined_for_current_feature?
179
+ @lines_for_features && !@lines_for_features[@feature_file].nil? && !@lines_for_features[@feature_file].empty?
180
+ end
181
+
182
+ def create_world
183
+ world = Object.new
184
+ @world_procs.each do |world_proc|
185
+ world = world_proc.call(world)
186
+ end
187
+ world
188
+ end
189
+ end
190
+ end
@@ -0,0 +1,109 @@
1
+ # Hack to work around Win32/Console, which bundles a licence-violating, outdated
2
+ # copy of term/ansicolor that doesn't implement Term::ANSIColor#coloring=.
3
+ # We want the official one!
4
+ gem 'term-ansicolor'
5
+ $LOAD_PATH.each{|path| $LOAD_PATH.unshift($LOAD_PATH.delete(path)) if path =~ /term-ansicolor/}
6
+ require 'term/ansicolor'
7
+
8
+ if $CUCUMBER_WINDOWS_MRI
9
+ begin
10
+ require 'Win32/Console/ANSI'
11
+ rescue LoadError
12
+ STDERR.puts "You must gem install win32console to get coloured output on MRI/Windows"
13
+ Term::ANSIColor.coloring = false
14
+ end
15
+ end
16
+
17
+ Term::ANSIColor.coloring = false if !STDOUT.tty? || ($CUCUMBER_WINDOWS && !$CUCUMBER_WINDOWS_MRI)
18
+
19
+ module Cucumber
20
+ module Formatters
21
+ # Adds ANSI color support to formatters.
22
+ # You can define your own colours by defining CUCUMBER_COLORS in your shell. Example:
23
+ #
24
+ # CUCUMBER_COLORS=pending=black,on_yellow:failed=dark,magenta:failed_param=bold,red
25
+ #
26
+ # The string must be a series of key=value pairs where:
27
+ #
28
+ # * Each key=value pair is separated by a colon (:)
29
+ # * Each key must be one of:
30
+ # ** passed
31
+ # ** passed_param
32
+ # ** failed
33
+ # ** failed_param
34
+ # ** skipped
35
+ # ** skipped_param
36
+ # ** pending
37
+ # * Each value must be a comma-separated string composed of:
38
+ # ** bold
39
+ # ** dark
40
+ # ** italic
41
+ # ** underline
42
+ # ** underscore
43
+ # ** blink
44
+ # ** rapid_blink
45
+ # ** negative
46
+ # ** concealed
47
+ # ** strikethrough
48
+ # ** black
49
+ # ** red
50
+ # ** green
51
+ # ** yellow
52
+ # ** blue
53
+ # ** magenta
54
+ # ** cyan
55
+ # ** white
56
+ # ** grey
57
+ # ** on_black
58
+ # ** on_red
59
+ # ** on_green
60
+ # ** on_yellow
61
+ # ** on_blue
62
+ # ** on_magenta
63
+ # ** on_cyan
64
+ # ** on_white
65
+ #
66
+ module ANSIColor
67
+ include ::Term::ANSIColor
68
+
69
+ # Params are underlined bold, except in windows, which doesn't support underline. Use non-bold colour.
70
+ param = PLATFORM =~ /mswin|mingw/ ? '' : 'underline,bold,'
71
+
72
+ # Default aliases
73
+ ALIASES = {
74
+ :passed => 'bold,green',
75
+ :passed_param => "#{param}green",
76
+ :failed => 'bold,red',
77
+ :failed_param => "#{param}red",
78
+ :skipped => 'bold,cyan',
79
+ :skipped_param => "#{param}cyan",
80
+ :pending => 'bold,yellow', # No pending_param
81
+ :comment => 'grey'
82
+ }
83
+ if ENV['CUCUMBER_COLORS']
84
+ ENV['CUCUMBER_COLORS'].split(':').each do |pair|
85
+ a = pair.split('=')
86
+ ALIASES[a[0].to_sym] = a[1]
87
+ end
88
+ end
89
+
90
+ # Not supported in Term::ANSIColor
91
+ def grey(m)
92
+ if ::Term::ANSIColor.coloring?
93
+ "\e[90m#{m}\e[0m"
94
+ else
95
+ m
96
+ end
97
+ end
98
+
99
+ ALIASES.each do |m, color_string|
100
+ colors = color_string.split(",").reverse
101
+ define_method(m) do |*s|
102
+ clear + colors.inject(s[0]) do |memo, color|
103
+ s[0].nil? ? __send__(color) + memo.to_s : __send__(color, memo.to_s)
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,23 @@
1
+ require 'cucumber/formatters/ansicolor'
2
+
3
+ module Cucumber
4
+ module Formatters
5
+ class AutotestFormatter
6
+ def initialize(io)
7
+ @io = io
8
+ @failed_scenarios = []
9
+ end
10
+
11
+ def step_didnt_pass(step, regexp, args)
12
+ unless @failed_scenarios.include? step.scenario.name
13
+ @failed_scenarios << step.scenario.name
14
+ @io.puts step.scenario.name
15
+ end
16
+ end
17
+
18
+ alias step_failed step_didnt_pass
19
+ alias step_pending step_didnt_pass
20
+ alias step_skipped step_didnt_pass
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,132 @@
1
+ body {
2
+ background: #fff;
3
+ font-size: 80%;
4
+ margin:0pt;
5
+ padding:0pt;
6
+ }
7
+
8
+ #container {
9
+ background:white none repeat scroll 0%;
10
+ font-family:Helvetica,Arial,sans-serif;
11
+ margin:0pt auto;
12
+ position:relative;
13
+ text-align:left;
14
+ top:1.0em;
15
+ width:78em;
16
+ }
17
+
18
+ span {
19
+ font-weight: bold;
20
+ text-decoration: underline;
21
+ }
22
+
23
+ dl {
24
+ font: normal 11px "Lucida Grande", Helvetica, sans-serif;
25
+ margin-left: 5px;
26
+ }
27
+
28
+ dl.new {
29
+ border-left: 5px solid #444444;
30
+ }
31
+
32
+ dl.pending {
33
+ border-left: 5px solid #FAF834;
34
+ }
35
+
36
+ dl.failed {
37
+ border-left: 5px solid #C20000;
38
+ }
39
+
40
+ dl.passed {
41
+ border-left: 5px solid #65C400;
42
+ }
43
+
44
+ dt {
45
+ color: #fff;
46
+ padding: 3px;
47
+ font-weight: bold;
48
+ }
49
+
50
+ dl.new > dt {
51
+ background: #444444;
52
+ }
53
+
54
+ dl.pending > dt {
55
+ color: #131313;
56
+ background: #FAF834;
57
+ }
58
+
59
+ dl.failed > dt {
60
+ background: #C20000;
61
+ }
62
+
63
+ dl.passed > dt {
64
+ background: #65C400;
65
+ }
66
+
67
+ dd {
68
+ margin: 0px 0px 0px 0px;
69
+ }
70
+
71
+ dd p, pre {
72
+ padding: 5px;
73
+ margin-top: 0;
74
+ margin-bottom: 5px;
75
+ }
76
+
77
+ dl.passed > dd > p, li.passed {
78
+ background: #DBFFB4; color: #3D7700;
79
+ border-bottom: 1px solid #65C400;
80
+ }
81
+
82
+ dl.failed > dd > p, li.failed {
83
+ color: #C20000; background: #FFFBD3;
84
+ border-bottom: 1px solid #C20000;
85
+ }
86
+
87
+ dl.pending > dd > p, li.pending {
88
+ color: #131313; background: #FCFB98;
89
+ border-bottom: 1px solid #FAF834;
90
+ }
91
+
92
+ dl.new > dd > p, li.new {
93
+ color: #444444; background: #DDDDDD;
94
+ border-bottom: 1px solid #444444;
95
+ }
96
+
97
+ span.param, span.param_editor {
98
+ font-weight: bold;
99
+ }
100
+
101
+ input {
102
+ width: 100%;
103
+ }
104
+
105
+ ul {
106
+ padding: 0px;
107
+ list-style: none;
108
+ }
109
+
110
+ ul > li {
111
+ margin: 5px 0px 5px 5px;
112
+ padding: 3px 3px 3px 5px;
113
+ }
114
+
115
+ div.auto_complete ul {
116
+ list-style-type: none;
117
+ border: 2px solid #F0F0F0;
118
+ margin: 0px;
119
+ padding: 0px;
120
+ }
121
+
122
+ div.auto_complete ul li {
123
+ background-color: white;
124
+ list-style-type: none;
125
+ display: block;
126
+ margin: 0;
127
+ padding: 2px;
128
+ }
129
+
130
+ div.auto_complete ul li.selected {
131
+ color: #444444; background: #DDDDDD;
132
+ }
@@ -0,0 +1,11 @@
1
+ function stepPassed(id) {
2
+ $("#"+id).removeClass("new").addClass("passed");
3
+ }
4
+
5
+ function stepPending(id) {
6
+ $("#"+id).removeClass("new").addClass("pending");
7
+ }
8
+
9
+ function stepFailed(id, message, backtrace) {
10
+ $("#"+id).removeClass("new").addClass("failed").append("<div>" + message + "</div>").append("<pre>" + backtrace + "</pre>");
11
+ }
@@ -0,0 +1,128 @@
1
+ module Cucumber
2
+ module Formatters
3
+ class HtmlFormatter
4
+ def initialize(io, step_mother)
5
+ @io = io
6
+ @step_mother = step_mother
7
+ @errors = []
8
+ @scenario_table_header = []
9
+ end
10
+
11
+ def visit_features(features)
12
+ # IMPORTANT NOTICE ABOUT JQUERY BELOW. THE ORIGINAL BACKSLASHES (\) HAVE
13
+ # BEEN REPLACED BY DOUBLE BACKSLASHES (\\) IN THIS FILE TO MAKE SURE THEY
14
+ # ARE PRINTED PROPERLY WITH ONLY ONE BACKSLASH (\).
15
+ @io.puts(<<-HTML)
16
+ <?xml version="1.0" encoding="UTF-8"?>
17
+ <!DOCTYPE html
18
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
19
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
20
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
21
+ <head>
22
+ <title>#{Cucumber.language['feature']}</title>
23
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
24
+ <meta http-equiv="Expires" content="-1" />
25
+ <meta http-equiv="Pragma" content="no-cache" />
26
+ <script type="text/javascript">
27
+ #{IO.read(File.dirname(__FILE__) + '/jquery.js')}
28
+ #{IO.read(File.dirname(__FILE__) + '/cucumber.js')}
29
+ </script>
30
+ <style>
31
+ #{IO.read(File.dirname(__FILE__) + '/cucumber.css')}
32
+ </style>
33
+ </head>
34
+ <body>
35
+ <div id="container">
36
+ HTML
37
+ features.accept(self)
38
+ @io.puts %{ </div>}
39
+ end
40
+
41
+ def visit_feature(feature)
42
+ @io.puts %{ <dl class="feature new">}
43
+ feature.accept(self)
44
+ @io.puts %{ </dd>}
45
+ @io.puts %{ </dl>}
46
+ end
47
+
48
+ def visit_header(header)
49
+ header = header.gsub(/\n/, "<br />\n")
50
+ @io.puts %{ <dt>#{header}}
51
+ @io.puts %{ </dt>}
52
+ @io.puts %{ <dd>}
53
+ end
54
+
55
+ def visit_regular_scenario(scenario)
56
+ @scenario_table_header = scenario.table_header
57
+ @io.puts %{ <dl class="new">}
58
+ @io.puts %{ <dt>#{Cucumber.language['scenario']}: #{scenario.name}</dt>}
59
+ @io.puts %{ <dd>}
60
+ @io.puts %{ <ul>}
61
+ scenario.accept(self)
62
+ @io.puts %{ </ul>}
63
+ @io.puts %{ </dd>}
64
+ @io.puts %{ </dl>}
65
+ end
66
+
67
+ def visit_row_scenario(scenario)
68
+ @io.puts %{ <dl class="new">}
69
+ @io.puts %{ <dt>#{Cucumber.language['scenario']}: #{scenario.name}</dt>}
70
+ @io.puts %{ <dd>}
71
+ @io.puts %{ <table cellpadding="3">}
72
+ @io.puts %{ <thead>}
73
+ @io.puts %{ <tr>}
74
+ @scenario_table_header.each do |column_header|
75
+ @io.puts %{ <th>#{column_header}</th>}
76
+ end
77
+ @io.puts %{ </tr>}
78
+ @io.puts %{ </thead>}
79
+ @io.puts %{ <tbody>}
80
+ scenario.accept(self)
81
+ @io.puts %{ </tbody>}
82
+ @io.puts %{ </table>}
83
+ @io.puts %{ </dd>}
84
+ @io.puts %{ </dl>}
85
+ end
86
+
87
+ def visit_row_step(step)
88
+ _, args, _ = step.regexp_args_proc(@step_mother)
89
+ args.each do |arg|
90
+ @io.puts %{ <td id="#{step.id}"><span>#{arg}</span></td>}
91
+ end
92
+ end
93
+
94
+ def visit_regular_step(step)
95
+ regexp, _, _ = step.regexp_args_proc(@step_mother)
96
+ @io.puts %{ <li class="new" id="#{step.id}">#{step.keyword} #{step.format(regexp, '<span>%s</span>')}</li>}
97
+ end
98
+
99
+ def step_passed(step, regexp, args)
100
+ print_javascript_tag("stepPassed(#{step.id})")
101
+ end
102
+
103
+ def step_failed(step, regexp, args)
104
+ @errors << step.error
105
+ print_javascript_tag("stepFailed(#{step.id}, #{step.error.message.inspect}, #{step.error.backtrace.join("\n").inspect})")
106
+ end
107
+
108
+ def step_pending(step, regexp, args)
109
+ print_javascript_tag("stepPending(#{step.id})")
110
+ end
111
+
112
+ def step_skipped(step, regexp, args)
113
+ # noop
114
+ end
115
+
116
+ def print_javascript_tag(js)
117
+ @io.puts %{ <script type="text/javascript">#{js}</script>}
118
+ end
119
+
120
+ def dump
121
+ @io.puts <<-HTML
122
+ </body>
123
+ </html>
124
+ HTML
125
+ end
126
+ end
127
+ end
128
+ end