aslakhellesoy-cucumber 0.1.5 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data/History.txt +228 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +226 -0
  4. data/README.txt +41 -0
  5. data/Rakefile +9 -0
  6. data/TODO.txt +26 -0
  7. data/bin/cucumber +5 -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 +31 -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/en/Rakefile +5 -0
  34. data/examples/i18n/en/features/addition.feature +17 -0
  35. data/examples/i18n/en/features/division.feature +10 -0
  36. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +31 -0
  37. data/examples/i18n/en/lib/calculator.rb +14 -0
  38. data/examples/i18n/es/Rakefile +6 -0
  39. data/examples/i18n/es/features/adicion.feature +17 -0
  40. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +22 -0
  41. data/examples/i18n/es/lib/calculador.rb +11 -0
  42. data/examples/i18n/et/Rakefile +6 -0
  43. data/examples/i18n/et/features/liitmine.feature +17 -0
  44. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +26 -0
  45. data/examples/i18n/et/lib/kalkulaator.rb +10 -0
  46. data/examples/i18n/fr/Rakefile +6 -0
  47. data/examples/i18n/fr/features/addition.feature +13 -0
  48. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +22 -0
  49. data/examples/i18n/fr/lib/calculatrice.rb +10 -0
  50. data/examples/i18n/id/Rakefile +6 -0
  51. data/examples/i18n/id/features/addition.feature +17 -0
  52. data/examples/i18n/id/features/division.feature +10 -0
  53. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +31 -0
  54. data/examples/i18n/id/lib/calculator.rb +14 -0
  55. data/examples/i18n/it/Rakefile +6 -0
  56. data/examples/i18n/it/features/somma.feature +10 -0
  57. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +22 -0
  58. data/examples/i18n/it/lib/calcolatrice.rb +11 -0
  59. data/examples/i18n/ja/README.txt +5 -0
  60. data/examples/i18n/ja/Rakefile +6 -0
  61. data/examples/i18n/ja/features/addition.feature +17 -0
  62. data/examples/i18n/ja/features/division.feature +10 -0
  63. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +30 -0
  64. data/examples/i18n/ja/lib/calculator.rb +14 -0
  65. data/examples/i18n/no/Rakefile +6 -0
  66. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +22 -0
  67. data/examples/i18n/no/features/summering.feature +17 -0
  68. data/examples/i18n/no/lib/kalkulator.rb +11 -0
  69. data/examples/i18n/pt/Rakefile +6 -0
  70. data/examples/i18n/pt/features/adicao.feature +10 -0
  71. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +22 -0
  72. data/examples/i18n/pt/lib/calculadora.rb +10 -0
  73. data/examples/i18n/ro/Rakefile +6 -0
  74. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +22 -0
  75. data/examples/i18n/ro/features/suma.feature +10 -0
  76. data/examples/i18n/ro/lib/calculator.rb +11 -0
  77. data/examples/i18n/se/Rakefile +6 -0
  78. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +22 -0
  79. data/examples/i18n/se/features/summering.feature +17 -0
  80. data/examples/i18n/se/lib/kalkulator.rb +11 -0
  81. data/examples/i18n/zh-CN/Rakefile +6 -0
  82. data/examples/i18n/zh-CN/features/addition.feature +17 -0
  83. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +24 -0
  84. data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
  85. data/examples/java/README.textile +22 -0
  86. data/examples/java/Rakefile +12 -0
  87. data/examples/java/features/hello.feature +11 -0
  88. data/examples/java/features/step_definitons/hello_steps.rb +25 -0
  89. data/examples/java/features/step_definitons/tree_steps.rb +14 -0
  90. data/examples/java/features/tree.feature +9 -0
  91. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  92. data/examples/selenium/Rakefile +6 -0
  93. data/examples/selenium/features/search.feature +9 -0
  94. data/examples/selenium/features/step_definitons/stories_steps.rb +41 -0
  95. data/examples/tickets/Rakefile +11 -0
  96. data/examples/tickets/cucumber.yml +2 -0
  97. data/examples/tickets/features/step_definitons/tickets_steps.rb +32 -0
  98. data/examples/tickets/features/tickets.feature +22 -0
  99. data/examples/watir/Rakefile +6 -0
  100. data/examples/watir/features/search.feature +9 -0
  101. data/examples/watir/features/step_definitons/stories_steps.rb +51 -0
  102. data/features/see_features.feature +8 -0
  103. data/features/steps/features_steps.rb +9 -0
  104. data/gem_tasks/deployment.rake +34 -0
  105. data/gem_tasks/environment.rake +7 -0
  106. data/gem_tasks/features.rake +6 -0
  107. data/gem_tasks/fix_cr_lf.rake +10 -0
  108. data/gem_tasks/flog.rake +4 -0
  109. data/gem_tasks/gemspec.rake +6 -0
  110. data/gem_tasks/rspec.rake +21 -0
  111. data/gem_tasks/treetop.rake +41 -0
  112. data/lib/autotest/cucumber.rb +6 -0
  113. data/lib/autotest/cucumber_mixin.rb +109 -0
  114. data/lib/autotest/cucumber_rails.rb +6 -0
  115. data/lib/autotest/cucumber_rails_rspec.rb +6 -0
  116. data/lib/autotest/cucumber_rspec.rb +6 -0
  117. data/lib/autotest/discover.rb +9 -0
  118. data/lib/cucumber.rb +39 -0
  119. data/lib/cucumber/broadcaster.rb +20 -0
  120. data/lib/cucumber/cli.rb +269 -0
  121. data/lib/cucumber/core_ext/proc.rb +54 -0
  122. data/lib/cucumber/core_ext/string.rb +22 -0
  123. data/lib/cucumber/executor.rb +170 -0
  124. data/lib/cucumber/formatters.rb +1 -0
  125. data/lib/cucumber/formatters/ansicolor.rb +111 -0
  126. data/lib/cucumber/formatters/autotest_formatter.rb +23 -0
  127. data/lib/cucumber/formatters/cucumber.css +132 -0
  128. data/lib/cucumber/formatters/cucumber.js +11 -0
  129. data/lib/cucumber/formatters/html_formatter.rb +128 -0
  130. data/lib/cucumber/formatters/jquery.js +32 -0
  131. data/lib/cucumber/formatters/pretty_formatter.rb +234 -0
  132. data/lib/cucumber/formatters/profile_formatter.rb +92 -0
  133. data/lib/cucumber/formatters/progress_formatter.rb +58 -0
  134. data/lib/cucumber/languages.yml +235 -0
  135. data/lib/cucumber/model.rb +1 -0
  136. data/lib/cucumber/model/table.rb +28 -0
  137. data/lib/cucumber/rails/rspec.rb +12 -0
  138. data/lib/cucumber/rails/world.rb +73 -0
  139. data/lib/cucumber/rake/task.rb +101 -0
  140. data/lib/cucumber/step_methods.rb +49 -0
  141. data/lib/cucumber/step_mother.rb +89 -0
  142. data/lib/cucumber/tree.rb +18 -0
  143. data/lib/cucumber/tree/feature.rb +61 -0
  144. data/lib/cucumber/tree/features.rb +21 -0
  145. data/lib/cucumber/tree/given_scenario.rb +13 -0
  146. data/lib/cucumber/tree/scenario.rb +158 -0
  147. data/lib/cucumber/tree/step.rb +134 -0
  148. data/lib/cucumber/tree/table.rb +26 -0
  149. data/lib/cucumber/tree/top_down_visitor.rb +23 -0
  150. data/lib/cucumber/treetop_parser/feature.treetop.erb +206 -0
  151. data/lib/cucumber/treetop_parser/feature_ar.rb +1591 -0
  152. data/lib/cucumber/treetop_parser/feature_cy.rb +1591 -0
  153. data/lib/cucumber/treetop_parser/feature_da.rb +1591 -0
  154. data/lib/cucumber/treetop_parser/feature_de.rb +1591 -0
  155. data/lib/cucumber/treetop_parser/feature_en-tx.rb +1591 -0
  156. data/lib/cucumber/treetop_parser/feature_en.rb +1591 -0
  157. data/lib/cucumber/treetop_parser/feature_es.rb +1591 -0
  158. data/lib/cucumber/treetop_parser/feature_et.rb +1591 -0
  159. data/lib/cucumber/treetop_parser/feature_fr.rb +1591 -0
  160. data/lib/cucumber/treetop_parser/feature_id.rb +1591 -0
  161. data/lib/cucumber/treetop_parser/feature_it.rb +1591 -0
  162. data/lib/cucumber/treetop_parser/feature_ja.rb +1591 -0
  163. data/lib/cucumber/treetop_parser/feature_nl.rb +1591 -0
  164. data/lib/cucumber/treetop_parser/feature_no.rb +1591 -0
  165. data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
  166. data/lib/cucumber/treetop_parser/feature_pl.rb +1591 -0
  167. data/lib/cucumber/treetop_parser/feature_pt.rb +1591 -0
  168. data/lib/cucumber/treetop_parser/feature_ro.rb +1591 -0
  169. data/lib/cucumber/treetop_parser/feature_ro2.rb +1591 -0
  170. data/lib/cucumber/treetop_parser/feature_ru.rb +1591 -0
  171. data/lib/cucumber/treetop_parser/feature_se.rb +1591 -0
  172. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1591 -0
  173. data/lib/cucumber/version.rb +9 -0
  174. data/rails_generators/cucumber/USAGE +11 -0
  175. data/rails_generators/cucumber/cucumber_generator.rb +30 -0
  176. data/rails_generators/cucumber/templates/cucumber +7 -0
  177. data/rails_generators/cucumber/templates/cucumber.rake +7 -0
  178. data/rails_generators/cucumber/templates/env.rb +8 -0
  179. data/rails_generators/cucumber/templates/webrat_steps.rb +46 -0
  180. data/rails_generators/feature/USAGE +12 -0
  181. data/rails_generators/feature/feature_generator.rb +16 -0
  182. data/rails_generators/feature/templates/feature.erb +28 -0
  183. data/rails_generators/feature/templates/steps.erb +22 -0
  184. data/script/console +10 -0
  185. data/script/console.cmd +1 -0
  186. data/script/destroy +14 -0
  187. data/script/destroy.cmd +1 -0
  188. data/script/generate +14 -0
  189. data/script/generate.cmd +1 -0
  190. data/script/txt2html +74 -0
  191. data/script/txt2html.cmd +1 -0
  192. data/setup.rb +1585 -0
  193. data/spec/cucumber/broadcaster_spec.rb +27 -0
  194. data/spec/cucumber/cli_spec.rb +242 -0
  195. data/spec/cucumber/core_ext/proc_spec.rb +45 -0
  196. data/spec/cucumber/core_ext/string_spec.rb +34 -0
  197. data/spec/cucumber/executor_spec.rb +222 -0
  198. data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
  199. data/spec/cucumber/formatters/autotest_formatter_spec.rb +26 -0
  200. data/spec/cucumber/formatters/features.html +269 -0
  201. data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
  202. data/spec/cucumber/formatters/pretty_formatter_spec.rb +204 -0
  203. data/spec/cucumber/formatters/profile_formatter_spec.rb +192 -0
  204. data/spec/cucumber/formatters/progress_formatter_spec.rb +65 -0
  205. data/spec/cucumber/model/table_spec.rb +20 -0
  206. data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
  207. data/spec/cucumber/rails/stubs/test_help.rb +1 -0
  208. data/spec/cucumber/rails/world_spec.rb +11 -0
  209. data/spec/cucumber/sell_cucumbers.feature +19 -0
  210. data/spec/cucumber/step_mother_spec.rb +74 -0
  211. data/spec/cucumber/tree/feature_spec.rb +12 -0
  212. data/spec/cucumber/tree/row_scenario_spec.rb +25 -0
  213. data/spec/cucumber/tree/scenario_spec.rb +76 -0
  214. data/spec/cucumber/tree/step_spec.rb +50 -0
  215. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  216. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  217. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +98 -0
  218. data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
  219. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  220. data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
  221. data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
  222. data/spec/cucumber/treetop_parser/spaces.feature +10 -0
  223. data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
  224. data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
  225. data/spec/spec.opts +2 -0
  226. data/spec/spec_helper.rb +19 -0
  227. metadata +151 -35
@@ -0,0 +1,54 @@
1
+ module Cucumber
2
+ class ArityMismatchError < StandardError
3
+ end
4
+
5
+ module CoreExt
6
+ # Proc extension that allows a proc to be called in the context of any object.
7
+ # Also makes it possible to tack a name onto a Proc.
8
+ module CallIn
9
+ attr_accessor :name
10
+
11
+ def call_in(obj, *args)
12
+ obj.extend(mod)
13
+ if self != StepMother::PENDING && args.length != arity2
14
+ # We have to manually raise when the block has arity -1 (no pipes)
15
+ raise ArityMismatchError.new("expected #{arity2} block argument(s), got #{args.length}")
16
+ else
17
+ obj.__send__(meth, *args)
18
+ end
19
+ end
20
+
21
+ def arity2
22
+ arity == -1 ? 0 : arity
23
+ end
24
+
25
+ def to_backtrace_line
26
+ "#{file_colon_line}:in `#{name}'"
27
+ end
28
+
29
+ def to_comment_line
30
+ "# #{file_colon_line}"
31
+ end
32
+
33
+ def file_colon_line
34
+ path, line = *to_s.match(/[\d\w]+@(.*):(.*)>/)[1..2]
35
+ path = File.expand_path(path)
36
+ pwd = Dir.pwd
37
+ path = path[pwd.length+1..-1]
38
+ "#{path}:#{line}"
39
+ end
40
+
41
+ def meth
42
+ @meth ||= "__cucumber_#{object_id}"
43
+ end
44
+
45
+ def mod
46
+ p = self
47
+ m = meth
48
+ @mod ||= Module.new do
49
+ define_method(m, &p)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,22 @@
1
+ class String
2
+ def gzub(regexp, format=nil, &proc)
3
+ md = match(regexp)
4
+ raise "#{self.inspect} doesn't match #{regexp.inspect}" if md.nil?
5
+
6
+ s = dup
7
+ pos = 0
8
+ md.captures.each_with_index do |m, n|
9
+ replacement = if block_given?
10
+ proc.call(m)
11
+ else
12
+ format % m
13
+ end
14
+
15
+ if md.offset(n+1)[0]
16
+ s[md.offset(n+1)[0] + pos, m.length] = replacement
17
+ pos += replacement.length - m.length
18
+ end
19
+ end
20
+ s
21
+ end
22
+ end
@@ -0,0 +1,170 @@
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
8
+
9
+ def line=(line)
10
+ @line = line
11
+ end
12
+
13
+ def initialize(step_mother)
14
+ @world_proc = lambda do
15
+ Object.new
16
+ end
17
+ @before_scenario_procs = []
18
+ @after_scenario_procs = []
19
+ @after_step_procs = []
20
+ @step_mother = step_mother
21
+
22
+ @executed_scenarios = {}
23
+ @regular_scenario_cache = {}
24
+ end
25
+
26
+ def register_world_proc(&proc)
27
+ @world_proc = proc
28
+ end
29
+
30
+ def register_before_scenario_proc(&proc)
31
+ proc.extend(CoreExt::CallIn)
32
+ @before_scenario_procs << proc
33
+ end
34
+
35
+ def register_after_scenario_proc(&proc)
36
+ proc.extend(CoreExt::CallIn)
37
+ @after_scenario_procs << proc
38
+ end
39
+
40
+ def register_after_step_proc(&proc)
41
+ proc.extend(CoreExt::CallIn)
42
+ @after_step_procs << proc
43
+ end
44
+
45
+ def visit_features(features)
46
+ raise "Line number can only be specified when there is 1 feature. There were #{features.length}." if @line && features.length != 1
47
+ formatters.visit_features(features)
48
+ features.accept(self)
49
+ formatters.dump
50
+ end
51
+
52
+ def visit_feature(feature)
53
+ if accept_feature?(feature)
54
+ formatters.feature_executing(feature)
55
+ feature.accept(self)
56
+ @executed_scenarios = {}
57
+ @regular_scenario_cache = {}
58
+ end
59
+ end
60
+
61
+ def visit_header(header)
62
+ formatters.header_executing(header)
63
+ end
64
+
65
+ def visit_row_scenario(scenario)
66
+ execute_scenario(@regular_scenario_cache[scenario.name]) if executing_unprepared_row_scenario?(scenario)
67
+ visit_scenario(scenario)
68
+ end
69
+
70
+ def visit_regular_scenario(scenario)
71
+ @regular_scenario_cache[scenario.name] = scenario
72
+ visit_scenario(scenario)
73
+ end
74
+
75
+ def visit_scenario(scenario)
76
+ if accept_scenario?(scenario)
77
+ @executed_scenarios[scenario.name] = true
78
+ execute_scenario(scenario)
79
+ end
80
+ end
81
+
82
+ def execute_scenario(scenario)
83
+ @error = nil
84
+ @pending = nil
85
+
86
+ @world = @world_proc.call
87
+ @world.extend(Spec::Matchers) if defined?(Spec::Matchers)
88
+ define_step_call_methods(@world)
89
+
90
+ formatters.scenario_executing(scenario)
91
+ @before_scenario_procs.each{|p| p.call_in(@world, *[])}
92
+ scenario.accept(self)
93
+ @after_scenario_procs.each{|p| p.call_in(@world, *[])}
94
+ formatters.scenario_executed(scenario)
95
+ end
96
+
97
+ def accept_scenario?(scenario)
98
+ accept = true
99
+ accept &&= scenario.at_line?(@line) if @line
100
+ accept &&= @scenario_names.include? scenario.name if @scenario_names && !@scenario_names.empty?
101
+ accept
102
+ end
103
+
104
+ def accept_feature?(feature)
105
+ feature.scenarios.any? { |s| accept_scenario?(s) }
106
+ end
107
+
108
+ def visit_row_step(step)
109
+ visit_step(step)
110
+ end
111
+
112
+ def visit_regular_step(step)
113
+ visit_step(step)
114
+ end
115
+
116
+ def visit_step(step)
117
+ unless @pending || @error
118
+ begin
119
+ regexp, args, proc = step.regexp_args_proc(@step_mother)
120
+ formatters.step_executing(step, regexp, args)
121
+ step.execute_in(@world, regexp, args, proc)
122
+ @after_step_procs.each{|p| p.call_in(@world, *[])}
123
+ formatters.step_passed(step, regexp, args)
124
+ rescue Pending
125
+ record_pending_step(step, regexp, args)
126
+ rescue => e
127
+ @failed = true
128
+ @error = step.error = e
129
+ formatters.step_failed(step, regexp, args)
130
+ end
131
+ else
132
+ begin
133
+ regexp, args, proc = step.regexp_args_proc(@step_mother)
134
+ step.execute_in(@world, regexp, args, proc)
135
+ formatters.step_skipped(step, regexp, args)
136
+ rescue Pending
137
+ record_pending_step(step, regexp, args)
138
+ rescue Exception
139
+ formatters.step_skipped(step, regexp, args)
140
+ end
141
+ end
142
+ end
143
+
144
+ def record_pending_step(step, regexp, args)
145
+ @pending = true
146
+ formatters.step_pending(step, regexp, args)
147
+ end
148
+
149
+ def define_step_call_methods(world)
150
+ world.instance_variable_set('@__executor', self)
151
+ world.instance_eval do
152
+ class << self
153
+ def run_step(name)
154
+ _, args, proc = @__executor.instance_variable_get(:@step_mother).regexp_args_proc(name)
155
+ proc.call_in(self, *args)
156
+ end
157
+
158
+ %w{given when then and but}.each do |keyword|
159
+ alias_method Cucumber.language[keyword], :run_step
160
+ end
161
+ end
162
+ end
163
+ end
164
+
165
+ def executing_unprepared_row_scenario?(scenario)
166
+ accept_scenario?(scenario) && !@executed_scenarios[scenario.name]
167
+ end
168
+
169
+ end
170
+ end
@@ -0,0 +1 @@
1
+ %w{html pretty progress profile autotest}.each{|n| require "cucumber/formatters/#{n}_formatter"}
@@ -0,0 +1,111 @@
1
+ gem 'term-ansicolor'
2
+ # Hack to work around Win32/Console, which bundles a licence-violating, outdated
3
+ # copy of term/ansicolor that doesn't implement Term::ANSIColor#coloring=.
4
+ # We want the official one!
5
+ $LOAD_PATH.each{|path| $LOAD_PATH.unshift($LOAD_PATH.delete(path)) if path =~ /term-ansicolor/}
6
+
7
+ require 'term/ansicolor'
8
+ require 'rbconfig'
9
+
10
+ win = Config::CONFIG['host_os'] =~ /mswin|mingw/
11
+ jruby = defined?(JRUBY_VERSION)
12
+
13
+ begin
14
+ require 'Win32/Console/ANSI' if (win && !jruby)
15
+ rescue LoadError
16
+ STDERR.puts "You must gem install win32console to get coloured output on this ruby platform (#{PLATFORM})"
17
+ ::Term::ANSIColor.coloring = false
18
+ end
19
+ ::Term::ANSIColor.coloring = false if !STDOUT.tty? || (win && jruby)
20
+
21
+ module Cucumber
22
+ module Formatters
23
+ # Adds ANSI color support to formatters.
24
+ # You can define your own colours by defining CUCUMBER_COLORS in your shell. Example:
25
+ #
26
+ # CUCUMBER_COLORS=pending=black,on_yellow:failed=dark,magenta:failed_param=bold,red
27
+ #
28
+ # The string must be a series of key=value pairs where:
29
+ #
30
+ # * Each key=value pair is separated by a colon (:)
31
+ # * Each key must be one of:
32
+ # ** passed
33
+ # ** passed_param
34
+ # ** failed
35
+ # ** failed_param
36
+ # ** skipped
37
+ # ** skipped_param
38
+ # ** pending
39
+ # * Each value must be a comma-separated string composed of:
40
+ # ** bold
41
+ # ** dark
42
+ # ** italic
43
+ # ** underline
44
+ # ** underscore
45
+ # ** blink
46
+ # ** rapid_blink
47
+ # ** negative
48
+ # ** concealed
49
+ # ** strikethrough
50
+ # ** black
51
+ # ** red
52
+ # ** green
53
+ # ** yellow
54
+ # ** blue
55
+ # ** magenta
56
+ # ** cyan
57
+ # ** white
58
+ # ** grey
59
+ # ** on_black
60
+ # ** on_red
61
+ # ** on_green
62
+ # ** on_yellow
63
+ # ** on_blue
64
+ # ** on_magenta
65
+ # ** on_cyan
66
+ # ** on_white
67
+ #
68
+ module ANSIColor
69
+ include ::Term::ANSIColor
70
+
71
+ # Params are underlined bold, except in windows, which doesn't support underline. Use non-bold colour.
72
+ param = PLATFORM =~ /mswin|mingw/ ? '' : 'underline,bold,'
73
+
74
+ # Default aliases
75
+ ALIASES = {
76
+ :passed => 'bold,green',
77
+ :passed_param => "#{param}green",
78
+ :failed => 'bold,red',
79
+ :failed_param => "#{param}red",
80
+ :skipped => 'bold,cyan',
81
+ :skipped_param => "#{param}cyan",
82
+ :pending => 'bold,yellow', # No pending_param
83
+ :comment => 'grey'
84
+ }
85
+ if ENV['CUCUMBER_COLORS']
86
+ ENV['CUCUMBER_COLORS'].split(':').each do |pair|
87
+ a = pair.split('=')
88
+ ALIASES[a[0].to_sym] = a[1]
89
+ end
90
+ end
91
+
92
+ #Not supported in Term::ANSIColor
93
+ def grey(m)
94
+ if ::Term::ANSIColor.coloring?
95
+ "\e[90m#{m}\e[0m"
96
+ else
97
+ m
98
+ end
99
+ end
100
+
101
+ ALIASES.each do |m, color_string|
102
+ colors = color_string.split(",").reverse
103
+ define_method(m) do |*s|
104
+ clear + colors.inject(s[0]) do |memo, color|
105
+ s[0].nil? ? __send__(color) + memo.to_s : __send__(color, memo.to_s)
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ 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
+ }