aslakhellesoy-cucumber 0.1.99.4 → 0.1.99.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. data/History.txt +4 -1
  2. data/Manifest.txt +2 -10
  3. data/cucumber.yml +1 -0
  4. data/examples/cs/README.textile +1 -0
  5. data/examples/cs/Rakefile +12 -0
  6. data/examples/cs/compile.bat +1 -0
  7. data/examples/cs/features/addition.feature +16 -0
  8. data/examples/cs/features/step_definitons/calculator_steps.rb +19 -0
  9. data/examples/cs/src/demo/Calculator.cs +20 -0
  10. data/examples/dos_line_endings/Rakefile +6 -0
  11. data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
  12. data/examples/i18n/README.textile +18 -0
  13. data/examples/i18n/Rakefile +32 -0
  14. data/examples/i18n/ar/Rakefile +6 -0
  15. data/examples/i18n/ar/features/addition.feature +17 -0
  16. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +28 -0
  17. data/examples/i18n/ar/lib/calculator.rb +10 -0
  18. data/examples/i18n/da/Rakefile +6 -0
  19. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +24 -0
  20. data/examples/i18n/da/features/summering.feature +17 -0
  21. data/examples/i18n/da/lib/kalkulator.rb +11 -0
  22. data/examples/i18n/de/Rakefile +6 -0
  23. data/examples/i18n/de/features/addition.feature +16 -0
  24. data/examples/i18n/de/features/division.feature +9 -0
  25. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +24 -0
  26. data/examples/i18n/de/lib/calculator.rb +14 -0
  27. data/examples/i18n/en/Rakefile +6 -0
  28. data/examples/i18n/en/features/addition.feature +16 -0
  29. data/examples/i18n/en/features/division.feature +9 -0
  30. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +24 -0
  31. data/examples/i18n/en/lib/calculator.rb +14 -0
  32. data/examples/i18n/es/Rakefile +6 -0
  33. data/examples/i18n/es/features/adicion.feature +17 -0
  34. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +24 -0
  35. data/examples/i18n/es/lib/calculador.rb +11 -0
  36. data/examples/i18n/et/Rakefile +6 -0
  37. data/examples/i18n/et/features/liitmine.feature +17 -0
  38. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +24 -0
  39. data/examples/i18n/et/lib/kalkulaator.rb +10 -0
  40. data/examples/i18n/fi/Rakefile +6 -0
  41. data/examples/i18n/fi/features/jakolasku.feature +9 -0
  42. data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +24 -0
  43. data/examples/i18n/fi/features/yhteenlasku.feature +16 -0
  44. data/examples/i18n/fi/lib/laskin.rb +14 -0
  45. data/examples/i18n/fr/Rakefile +6 -0
  46. data/examples/i18n/fr/features/addition.feature +15 -0
  47. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +27 -0
  48. data/examples/i18n/fr/lib/calculatrice.rb +10 -0
  49. data/examples/i18n/id/Rakefile +6 -0
  50. data/examples/i18n/id/features/addition.feature +16 -0
  51. data/examples/i18n/id/features/division.feature +9 -0
  52. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +24 -0
  53. data/examples/i18n/id/lib/calculator.rb +14 -0
  54. data/examples/i18n/it/Rakefile +6 -0
  55. data/examples/i18n/it/features/somma.feature +10 -0
  56. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +24 -0
  57. data/examples/i18n/it/lib/calcolatrice.rb +11 -0
  58. data/examples/i18n/ja/README.txt +5 -0
  59. data/examples/i18n/ja/Rakefile +6 -0
  60. data/examples/i18n/ja/features/addition.feature +16 -0
  61. data/examples/i18n/ja/features/division.feature +9 -0
  62. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +24 -0
  63. data/examples/i18n/ja/lib/calculator.rb +14 -0
  64. data/examples/i18n/ko/Rakefile +6 -0
  65. data/examples/i18n/ko/features/addition.feature +16 -0
  66. data/examples/i18n/ko/features/division.feature +10 -0
  67. data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +24 -0
  68. data/examples/i18n/ko/lib/calculator.rb +14 -0
  69. data/examples/i18n/lt/Rakefile +6 -0
  70. data/examples/i18n/lt/features/addition.feature +17 -0
  71. data/examples/i18n/lt/features/division.feature +9 -0
  72. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +24 -0
  73. data/examples/i18n/lt/lib/calculator.rb +14 -0
  74. data/examples/i18n/no/Rakefile +6 -0
  75. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +24 -0
  76. data/examples/i18n/no/features/summering.feature +18 -0
  77. data/examples/i18n/no/lib/kalkulator.rb +11 -0
  78. data/examples/i18n/pt/Rakefile +6 -0
  79. data/examples/i18n/pt/features/adicao.feature +10 -0
  80. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +24 -0
  81. data/examples/i18n/pt/lib/calculadora.rb +10 -0
  82. data/examples/i18n/ro/Rakefile +6 -0
  83. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +24 -0
  84. data/examples/i18n/ro/features/suma.feature +10 -0
  85. data/examples/i18n/ro/lib/calculator.rb +11 -0
  86. data/examples/i18n/se/Rakefile +6 -0
  87. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +24 -0
  88. data/examples/i18n/se/features/summering.feature +17 -0
  89. data/examples/i18n/se/lib/kalkulator.rb +11 -0
  90. data/examples/i18n/zh-CN/Rakefile +6 -0
  91. data/examples/i18n/zh-CN/features/addition.feature +17 -0
  92. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +26 -0
  93. data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
  94. data/examples/java/README.textile +22 -0
  95. data/examples/java/Rakefile +12 -0
  96. data/examples/java/features/hello.feature +11 -0
  97. data/examples/java/features/step_definitons/hello_steps.rb +25 -0
  98. data/examples/java/features/step_definitons/tree_steps.rb +14 -0
  99. data/examples/java/features/tree.feature +9 -0
  100. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  101. data/examples/jbehave/README.textile +17 -0
  102. data/examples/jbehave/features/support/env.rb +7 -0
  103. data/examples/jbehave/features/trading.feature +24 -0
  104. data/examples/jbehave/pom.xml +48 -0
  105. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java +32 -0
  106. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java +42 -0
  107. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java +29 -0
  108. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java +22 -0
  109. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +65 -0
  110. data/examples/selenium/Rakefile +6 -0
  111. data/examples/selenium/features/search.feature +9 -0
  112. data/examples/selenium/features/step_definitons/stories_steps.rb +40 -0
  113. data/examples/self_test/README.textile +6 -0
  114. data/examples/self_test/features/call_undefined_step_from_step_def.feature +7 -0
  115. data/examples/self_test/features/lots_of_undefined.feature +8 -0
  116. data/examples/self_test/features/outline_sample.feature +15 -0
  117. data/examples/self_test/features/sample.feature +16 -0
  118. data/examples/self_test/features/step_definitions/sample_steps.rb +25 -0
  119. data/examples/test_unit/Rakefile +6 -0
  120. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +26 -0
  121. data/examples/test_unit/features/test_unit.feature +9 -0
  122. data/examples/tickets/Rakefile +11 -0
  123. data/examples/tickets/cucumber.yml +2 -0
  124. data/examples/tickets/features/lib/eatting_machine.rb +18 -0
  125. data/examples/tickets/features/lib/pantry.rb +20 -0
  126. data/examples/tickets/features/scenario_outline.feature +95 -0
  127. data/examples/tickets/features/step_definitons/scenario_outline_steps.rb +42 -0
  128. data/examples/tickets/features/step_definitons/tickets_steps.rb +60 -0
  129. data/examples/tickets/features/tickets.feature +28 -0
  130. data/examples/watir/README.textile +16 -0
  131. data/examples/watir/Rakefile +6 -0
  132. data/examples/watir/features/search.feature +9 -0
  133. data/examples/watir/features/step_definitons/search_steps.rb +24 -0
  134. data/examples/watir/features/support/env.rb +32 -0
  135. data/features/cucumber_cli.feature +331 -0
  136. data/features/cucumber_cli_outlines.feature +90 -0
  137. data/features/report_called_undefined_steps.feature +32 -0
  138. data/features/step_definitions/cucumber_steps.rb +31 -0
  139. data/features/step_definitions/extra_steps.rb +2 -0
  140. data/features/support/env.rb +7 -0
  141. data/gem_tasks/deployment.rake +11 -0
  142. data/gem_tasks/environment.rake +7 -0
  143. data/gem_tasks/features.rake +6 -0
  144. data/gem_tasks/fix_cr_lf.rake +10 -0
  145. data/gem_tasks/flog.rake +4 -0
  146. data/gem_tasks/gemspec.rake +10 -0
  147. data/gem_tasks/rspec.rake +35 -0
  148. data/gem_tasks/yard.rake +8 -0
  149. data/lib/autotest/cucumber.rb +6 -0
  150. data/lib/autotest/cucumber_mixin.rb +124 -0
  151. data/lib/autotest/cucumber_rails.rb +6 -0
  152. data/lib/autotest/cucumber_rails_rspec.rb +6 -0
  153. data/lib/autotest/cucumber_rspec.rb +6 -0
  154. data/lib/autotest/discover.rb +9 -0
  155. data/lib/cucumber.rb +72 -0
  156. data/lib/cucumber/ast.rb +27 -0
  157. data/lib/cucumber/ast/comment.rb +26 -0
  158. data/lib/cucumber/ast/examples.rb +22 -0
  159. data/lib/cucumber/ast/feature.rb +60 -0
  160. data/lib/cucumber/ast/features.rb +39 -0
  161. data/lib/cucumber/ast/filter.rb +22 -0
  162. data/lib/cucumber/ast/outline_table.rb +49 -0
  163. data/lib/cucumber/ast/py_string.rb +52 -0
  164. data/lib/cucumber/ast/scenario.rb +95 -0
  165. data/lib/cucumber/ast/scenario_outline.rb +83 -0
  166. data/lib/cucumber/ast/step.rb +139 -0
  167. data/lib/cucumber/ast/table.rb +214 -0
  168. data/lib/cucumber/ast/tags.rb +33 -0
  169. data/lib/cucumber/ast/visitor.rb +93 -0
  170. data/lib/cucumber/broadcaster.rb +15 -0
  171. data/lib/cucumber/cli.rb +414 -0
  172. data/lib/cucumber/core_ext/exception.rb +53 -0
  173. data/lib/cucumber/core_ext/instance_exec.rb +54 -0
  174. data/lib/cucumber/core_ext/proc.rb +33 -0
  175. data/lib/cucumber/core_ext/string.rb +48 -0
  176. data/lib/cucumber/formatter.rb +1 -0
  177. data/lib/cucumber/formatter/ansicolor.rb +106 -0
  178. data/lib/cucumber/formatter/console.rb +116 -0
  179. data/lib/cucumber/formatter/pretty.rb +158 -0
  180. data/lib/cucumber/formatter/profile.rb +77 -0
  181. data/lib/cucumber/formatter/progress.rb +68 -0
  182. data/lib/cucumber/formatter/rerun.rb +35 -0
  183. data/lib/cucumber/formatters/unicode.rb +2 -0
  184. data/lib/cucumber/jbehave.rb +104 -0
  185. data/lib/cucumber/languages.yml +314 -0
  186. data/lib/cucumber/parser.rb +24 -0
  187. data/lib/cucumber/parser/basic.rb +0 -0
  188. data/lib/cucumber/parser/feature.rb +1351 -0
  189. data/lib/cucumber/parser/feature.tt +160 -0
  190. data/lib/cucumber/parser/i18n.tt +27 -0
  191. data/lib/cucumber/parser/table.rb +396 -0
  192. data/lib/cucumber/parser/table.tt +53 -0
  193. data/lib/cucumber/parser/treetop_ext.rb +67 -0
  194. data/lib/cucumber/platform.rb +18 -0
  195. data/lib/cucumber/rails/rspec.rb +5 -0
  196. data/lib/cucumber/rails/world.rb +73 -0
  197. data/lib/cucumber/rake/task.rb +106 -0
  198. data/lib/cucumber/step_definition.rb +87 -0
  199. data/lib/cucumber/step_mother.rb +164 -0
  200. data/lib/cucumber/version.rb +10 -0
  201. data/pretty.txt +486 -0
  202. data/rails_generators/cucumber/USAGE +11 -0
  203. data/rails_generators/cucumber/cucumber_generator.rb +31 -0
  204. data/rails_generators/cucumber/templates/cucumber +8 -0
  205. data/rails_generators/cucumber/templates/cucumber.rake +7 -0
  206. data/rails_generators/cucumber/templates/env.rb +16 -0
  207. data/rails_generators/cucumber/templates/paths.rb +12 -0
  208. data/rails_generators/cucumber/templates/webrat_steps.rb +99 -0
  209. data/rails_generators/feature/USAGE +12 -0
  210. data/rails_generators/feature/feature_generator.rb +36 -0
  211. data/rails_generators/feature/templates/feature.erb +31 -0
  212. data/rails_generators/feature/templates/steps.erb +24 -0
  213. data/spec/cucumber/ast/feature_factory.rb +54 -0
  214. data/spec/cucumber/ast/feature_spec.rb +60 -0
  215. data/spec/cucumber/ast/py_string_spec.rb +40 -0
  216. data/spec/cucumber/ast/scenario_outline_spec.rb +64 -0
  217. data/spec/cucumber/ast/scenario_spec.rb +82 -0
  218. data/spec/cucumber/ast/step_spec.rb +45 -0
  219. data/spec/cucumber/ast/table_spec.rb +81 -0
  220. data/spec/cucumber/broadcaster_spec.rb +14 -0
  221. data/spec/cucumber/cli_spec.rb +416 -0
  222. data/spec/cucumber/core_ext/proc_spec.rb +37 -0
  223. data/spec/cucumber/core_ext/string_spec.rb +42 -0
  224. data/spec/cucumber/formatter/ansicolor_spec.rb +35 -0
  225. data/spec/cucumber/formatter/html/cucumber.css +37 -0
  226. data/spec/cucumber/formatter/html/cucumber.js +13 -0
  227. data/spec/cucumber/formatter/html/index.html +45 -0
  228. data/spec/cucumber/formatter/html/jquery-1.3.min.js +19 -0
  229. data/spec/cucumber/formatter/html/jquery.uitableedit.js +100 -0
  230. data/spec/cucumber/formatters/profile_formatter_spec.rb +198 -0
  231. data/spec/cucumber/parser/feature_parser_spec.rb +247 -0
  232. data/spec/cucumber/parser/table_parser_spec.rb +48 -0
  233. data/spec/cucumber/rails/stubs/mini_rails.rb +18 -0
  234. data/spec/cucumber/rails/stubs/test_help.rb +1 -0
  235. data/spec/cucumber/rails/world_spec.rb +11 -0
  236. data/spec/cucumber/sell_cucumbers.feature +19 -0
  237. data/spec/cucumber/step_definition_spec.rb +62 -0
  238. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  239. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  240. data/spec/cucumber/treetop_parser/empty_scenario_outline.feature +3 -0
  241. data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
  242. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  243. data/spec/cucumber/treetop_parser/invalid_scenario_outlines.feature +7 -0
  244. data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
  245. data/spec/cucumber/treetop_parser/multiple_tables.feature +27 -0
  246. data/spec/cucumber/treetop_parser/scenario_outline.feature +16 -0
  247. data/spec/cucumber/treetop_parser/spaces.feature +12 -0
  248. data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
  249. data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
  250. data/spec/cucumber/treetop_parser/with_tags.feature +18 -0
  251. data/spec/cucumber/world/pending_spec.rb +47 -0
  252. data/spec/spec.opts +2 -0
  253. data/spec/spec_helper.rb +21 -0
  254. metadata +7 -1
@@ -0,0 +1,77 @@
1
+ require 'cucumber/formatter/progress'
2
+
3
+ module Cucumber
4
+ module Formatter
5
+ class Profile < Progress
6
+ NUMBER_OF_STEP_DEFINITONS_TO_SHOW = 10
7
+ NUMBER_OF_STEP_INVOCATIONS_TO_SHOW = 5
8
+
9
+ def initialize(step_mother, io, options)
10
+ super
11
+ @step_definition_durations = Hash.new { |h,step_definition| h[step_definition] = [] }
12
+ end
13
+
14
+ def visit_step(step)
15
+ @step_duration = Time.now
16
+ @step = step
17
+ super
18
+ end
19
+
20
+ def visit_step_name(keyword, step_name, status, step_definition, source_indent)
21
+ duration = Time.now - @step_duration
22
+ super
23
+
24
+ if step_definition # nil for outline steps
25
+ description = format_step(keyword, step_name, status, step_definition, nil)
26
+ @step_definition_durations[step_definition] << [duration, description, @step.file_line]
27
+ end
28
+ end
29
+
30
+ def print_summary(features)
31
+ super
32
+ @io.puts "\n\nTop #{NUMBER_OF_STEP_DEFINITONS_TO_SHOW} average slowest steps with #{NUMBER_OF_STEP_INVOCATIONS_TO_SHOW} slowest matches:\n"
33
+
34
+ mean_durations = map_to_mean_durations(@step_definition_durations)
35
+ mean_durations = mean_durations.sort_by do |duration_description_location, step_definition, mean_duration|
36
+ mean_duration
37
+ end.reverse
38
+
39
+ mean_durations[0...NUMBER_OF_STEP_DEFINITONS_TO_SHOW].each do |duration_description_location, step_definition, mean_duration|
40
+ print_step_definition(step_definition, mean_duration)
41
+ duration_description_location = duration_description_location.sort_by do |duration, description, location|
42
+ duration
43
+ end.reverse
44
+ print_step_definitions(duration_description_location, step_definition)
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def map_to_mean_durations(step_definition_durations)
51
+ mean_durations = []
52
+ step_definition_durations.each do |step_definition, duration_description_location|
53
+ total_duration = duration_description_location.inject(0) { |sum, step_details| step_details[0] + sum }
54
+ mean_duration = total_duration / duration_description_location.length
55
+
56
+ mean_durations << [duration_description_location, step_definition, mean_duration]
57
+ end
58
+ mean_durations
59
+ end
60
+
61
+ def print_step_definition(step_definition, mean_duration)
62
+ duration = sprintf("%.7f", mean_duration)
63
+ @io.puts format_string("#{duration} #{step_definition.to_backtrace_line}", :failed)
64
+ end
65
+
66
+ def print_step_definitions(duration_description_location, step_definition)
67
+ max_length = duration_description_location[0...NUMBER_OF_STEP_INVOCATIONS_TO_SHOW].map{|_, d, _| d.jlength}.max
68
+ duration_description_location[0...NUMBER_OF_STEP_INVOCATIONS_TO_SHOW].each do |duration, description, location|
69
+ @io.print format_string(" #{sprintf("%.7f", duration)}", :pending)
70
+ @io.print " #{description}"
71
+ @io.print format_string(" # #{location}".indent(max_length - description.jlength), :comment)
72
+ @io.puts
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,68 @@
1
+ require 'cucumber/formatter/console'
2
+
3
+ module Cucumber
4
+ module Formatter
5
+ class Progress < Ast::Visitor
6
+ include Console
7
+
8
+ def initialize(step_mother, io, options)
9
+ super(step_mother)
10
+ @io = io
11
+ @options = options
12
+ end
13
+
14
+ def visit_features(features)
15
+ with_color do
16
+ super
17
+ @io.puts
18
+ @io.puts
19
+ print_summary(features)
20
+ end
21
+ end
22
+
23
+ def visit_multiline_arg(multiline_arg, status)
24
+ @multiline_arg = true
25
+ super
26
+ @multiline_arg = false
27
+ end
28
+
29
+ def visit_feature_element(feature_element)
30
+ progress(:undefined) if feature_element.undefined?
31
+ super
32
+ end
33
+
34
+ def visit_step_name(keyword, step_name, status, step_definition, source_indent)
35
+ progress(status) unless status == :outline
36
+ end
37
+
38
+ def visit_table_cell_value(value, width, status)
39
+ progress(status) if (status != :thead) && !@multiline_arg
40
+ end
41
+
42
+ private
43
+
44
+ def print_summary(features)
45
+ print_undefined_scenarios(features)
46
+ print_steps(features, :pending)
47
+ print_steps(features, :failed)
48
+ print_counts(features)
49
+ print_snippets(features, @options)
50
+ end
51
+
52
+ CHARS = {
53
+ :passed => '.',
54
+ :failed => 'F',
55
+ :undefined => 'U',
56
+ :pending => 'P',
57
+ :skipped => 'S'
58
+ }
59
+
60
+ def progress(status)
61
+ char = CHARS[status]
62
+ @io.print(format_string(char, status))
63
+ @io.flush
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,35 @@
1
+ module Cucumber
2
+ module Formatter
3
+ class Rerun < Ast::Visitor
4
+ def initialize(step_mother, io, options)
5
+ super(step_mother)
6
+ @io = io
7
+ @file_names = []
8
+ @file_lines = Hash.new{|h,k| h[k] = []}
9
+ end
10
+
11
+ def visit_features(features)
12
+ super
13
+ files = @file_names.uniq.map do |file|
14
+ lines = @file_lines[file]
15
+ "#{file}:#{lines.join(':')}"
16
+ end
17
+ @io.puts files.join(' ')
18
+ end
19
+
20
+ def visit_feature_element(feature_element)
21
+ @rerun = false
22
+ super
23
+ if @rerun
24
+ file, line = *feature_element.file_line.split(':')
25
+ @file_lines[file] << line
26
+ @file_names << file
27
+ end
28
+ end
29
+
30
+ def visit_step_name(keyword, step_name, status, step_definition, source_indent)
31
+ @rerun = true if [:failed].index(status)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,2 @@
1
+ # This is for backwards compatibility
2
+ require 'cucumber/formatter/unicode'
@@ -0,0 +1,104 @@
1
+ require 'java'
2
+
3
+ $:.unshift(ENV['HOME'] + '/.m2/repository/org/hamcrest/hamcrest-all/1.1')
4
+ $:.unshift(ENV['HOME'] + '/.m2/repository/junit/junit/4.4')
5
+ $:.unshift(ENV['HOME'] + '/.m2/repository/org/jbehave/jbehave-core/2.1')
6
+
7
+ require 'hamcrest-all-1.1.jar'
8
+ require 'junit-4.4.jar'
9
+ require 'jbehave-core-2.1.jar'
10
+
11
+ Exception::CUCUMBER_FILTER_PATTERNS.unshift(/^org\/jruby|^org\/jbehave|^org\/junit|^java\/|^sun\/|^\$_dot_dot_/)
12
+
13
+ module Cucumber
14
+ module JBehave
15
+ # Register an instance of org.jbehave.scenario.steps.Steps
16
+ def JBehave(jbehave_steps)
17
+ jbehave_steps.getSteps.each do |jbehave_candidate_step|
18
+ step_definitions << JBehaveStepDefinition.new(jbehave_steps, jbehave_candidate_step)
19
+ end
20
+ end
21
+
22
+ # Open up so we can get the pattern....
23
+ JBehaveCandidateStep = org.jbehave.scenario.steps.CandidateStep
24
+ class JBehaveCandidateStep
25
+ field_reader :pattern
26
+ end
27
+
28
+ # Adapter for JBehave org.jbehave.scenario.steps.CandidateStep
29
+ class JBehaveStepDefinition
30
+ def initialize(jbehave_steps, jbehave_candidate_step)
31
+ @jbehave_steps = jbehave_steps
32
+ @jbehave_candidate_step = jbehave_candidate_step
33
+ end
34
+
35
+ def match(step_name)
36
+ full_text = "Given #{step_name}" # JBehave doesn't distinguish GWT internally :-)
37
+ @jbehave_candidate_step.matches(full_text)
38
+ end
39
+
40
+ def file_colon_line
41
+ @jbehave_steps.java_class.name
42
+ end
43
+
44
+ def format_args(step_name, format)
45
+ java_pattern = @jbehave_candidate_step.pattern.pattern
46
+ regexp = Regexp.new(java_pattern)
47
+ step_name.gzub(regexp, format)
48
+ end
49
+
50
+ def matched_args(step_name)
51
+ java_pattern = @jbehave_candidate_step.pattern.pattern
52
+ regexp = Regexp.new(java_pattern)
53
+ step_name.match(regexp).captures
54
+ end
55
+
56
+ def execute(step_name, world, *args)
57
+ step = @jbehave_candidate_step.createFrom("Given #{step_name}")
58
+ result = step.perform
59
+ result.describeTo(JBehave::REPORTER)
60
+ end
61
+ end
62
+
63
+ class JBehaveException < Exception
64
+ end
65
+
66
+ # Implements the org.jbehave.scenario.reporters.ScenarioReporter methods
67
+ class Reporter
68
+ def successful(step_text)
69
+ # noop
70
+ end
71
+
72
+ def failed(step, java_exception)
73
+ raise java_exception_to_ruby_exception(java_exception)
74
+ end
75
+
76
+ private
77
+
78
+ def java_exception_to_ruby_exception(java_exception)
79
+ # OK, this is a little funky - JRuby weirdness
80
+ ruby_exception = org.jruby.NativeException.new(JRuby.runtime, JBehaveException, java_exception)
81
+ ruby_exception.set_backtrace([]) # work around backtrace bug in jruby
82
+
83
+ exception = JBehaveException.new(java_exception.getMessage)
84
+ bt = ruby_exception.backtrace
85
+ Exception.cucumber_strip_backtrace!(bt, nil, nil)
86
+ exception.set_backtrace(bt)
87
+ exception
88
+ end
89
+ end
90
+
91
+ REPORTER = Reporter.new
92
+
93
+ def self.snippet_text(step_keyword, step_name)
94
+ camel = step_name.gsub(/(\s.)/) {$1.upcase.strip}
95
+ method = camel[0..0].downcase + camel[1..-1]
96
+ snippet = %{ @#{step_keyword}("#{step_name}")
97
+ public void #{method}() {
98
+ }}
99
+ end
100
+ end
101
+ end
102
+
103
+ self.extend(Cucumber::JBehave)
104
+ self.snippet_generator = Cucumber::JBehave
@@ -0,0 +1,314 @@
1
+ # encoding: UTF-8
2
+ # We use the codes here (prefer 2 letters when possible)
3
+ # http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
4
+ #
5
+ "en":
6
+ name: English
7
+ native: English
8
+ encoding: UTF-8
9
+ feature: Feature
10
+ background: Background
11
+ scenario: Scenario
12
+ scenario_outline: Scenario Outline
13
+ examples: Examples
14
+ given: Given
15
+ when: When
16
+ then: Then
17
+ and: And
18
+ but: But
19
+ # Please help us keeping the languages below uptodate. The parsers for a language
20
+ # that is missing a keyword will expect the English word until the missing word(s)
21
+ # are added.
22
+ #
23
+ # Please keep the grammars in alphabetical order by name from here and down.
24
+
25
+ "ar":
26
+ name: Arabic
27
+ native: العربية
28
+ encoding: UTF-8
29
+ feature: خاصية
30
+ scenario: سيناريو
31
+ given: بفرض
32
+ when: متى
33
+ then: اذاً
34
+ and: و
35
+ but: لكن
36
+ "cy":
37
+ name: Welsh
38
+ native: Cymraeg
39
+ encoding: UTF-8
40
+ feature: Arwedd
41
+ scenario: Scenario
42
+ examples: Enghreifftiau
43
+ given: anrhegedig a
44
+ when: Pryd
45
+ then: Yna
46
+ and: A
47
+ but: Ond
48
+ "da":
49
+ name: Danish
50
+ native: dansk
51
+ encoding: UTF-8
52
+ feature: Egenskab
53
+ background: Baggrund
54
+ scenario: Scenarie
55
+ scenario_outline: Abstrakt Scenario
56
+ examples: Eksempler
57
+ given: Givet
58
+ when: Når
59
+ then: Så
60
+ and: Og
61
+ but: Men
62
+ "de":
63
+ name: German
64
+ native: Deutsch
65
+ encoding: UTF-8
66
+ feature: Funktionalität
67
+ scenario: Szenario
68
+ scenario_outline: Szenariogrundriss
69
+ examples: Beispiele
70
+ given: Gegeben sei
71
+ when: Wenn
72
+ then: Dann
73
+ and: Und
74
+ but: Aber
75
+ "en-lol":
76
+ name: LOLCAT
77
+ native: LOLCAT
78
+ encoding: UTF-8
79
+ feature: OH HAI
80
+ background: B4
81
+ scenario: MISHUN
82
+ scenario_outline: MISHUN SRSLY
83
+ examples: EXAMPLZ
84
+ given: GIVN
85
+ when: WEN
86
+ then: DEN
87
+ and: AN
88
+ but: BUT
89
+ "en-tx":
90
+ name: Texan
91
+ native: Texan
92
+ encoding: UTF-8
93
+ feature: Feature
94
+ scenario: Scenario
95
+ scenario_outline: Scenario Outline
96
+ examples: Examples
97
+ given: Given y'all
98
+ when: When y'all
99
+ then: Then y'all
100
+ and: And y'all
101
+ but: But y'all
102
+ "es":
103
+ name: Spanish
104
+ native: español
105
+ encoding: UTF-8
106
+ feature: Característica
107
+ scenario: Escenario
108
+ given: Dado
109
+ when: Cuando
110
+ then: Entonces
111
+ and: Y
112
+ but: Pero
113
+ "et":
114
+ name: Estonian
115
+ native: eesti keel
116
+ encoding: UTF-8
117
+ feature: Omadus
118
+ scenario: Stsenaarium
119
+ given: Eeldades
120
+ when: Kui
121
+ then: Siis
122
+ and: Ja
123
+ but: Kuid
124
+ "fi":
125
+ name: Finnish
126
+ native: suomi
127
+ encoding: UTF-8
128
+ feature: Ominaisuus
129
+ scenario: Tapaus
130
+ scenario_outline: Tapausaihio
131
+ examples: Tapaukset
132
+ given: Oletetaan
133
+ when: Kun
134
+ then: Niin
135
+ and: Ja
136
+ but: Mutta
137
+ "fr":
138
+ name: French
139
+ native: français
140
+ encoding: UTF-8
141
+ feature: Fonctionnalité
142
+ scenario: Scénario
143
+ scenario_outline: Scénario esquisse
144
+ examples: Exemples
145
+ given: Etant donné
146
+ when: Lorsque
147
+ then: Alors
148
+ and: Et
149
+ but: Mais
150
+ "id":
151
+ name: Indonesian
152
+ native: Bahasa Indonesia
153
+ encoding: UTF-8
154
+ feature: Fitur
155
+ scenario: Skenario
156
+ scenario_outline: Skenario konsep
157
+ examples: Contoh
158
+ given: Dengan
159
+ when: Ketika
160
+ then: Maka
161
+ and: Dan
162
+ but: Tapi
163
+ "it":
164
+ name: Italian
165
+ native: italiano
166
+ encoding: UTF-8
167
+ feature: Funzionalità
168
+ scenario: Scenario
169
+ more_examples: Più esempi
170
+ given: Dato
171
+ when: Quando
172
+ then: Allora
173
+ and: E
174
+ but: Ma
175
+ "ja":
176
+ name: Japanese
177
+ native: 日本語
178
+ encoding: Shift_JIS
179
+ feature: フィーチャ
180
+ scenario: シナリオ
181
+ more_examples: 他のサンプル
182
+ given: 前提
183
+ when: もし
184
+ then: ならば
185
+ and: かつ
186
+ but: しかし
187
+ "lt":
188
+ name: Lithuanian
189
+ native: lietuvių kalba
190
+ encoding: UTF-8
191
+ feature: Sąvybė
192
+ scenario: Scenarijus
193
+ examples: Pavyzdžių
194
+ given: Duota
195
+ when: Kai
196
+ then: Tada
197
+ and: Ir
198
+ but: Bet
199
+ "nl":
200
+ name: Dutch
201
+ native: Nederlands
202
+ encoding: UTF-8
203
+ feature: Functionaliteit
204
+ scenario: Scenario
205
+ given: Gegeven
206
+ when: Als
207
+ then: Dan
208
+ and: En
209
+ but: Maar
210
+ "no":
211
+ name: Norwegian
212
+ native: norsk
213
+ encoding: UTF-8
214
+ feature: Egenskap
215
+ background: Bakgrunn
216
+ scenario: Scenario
217
+ scenario_outline: Abstrakt Scenario
218
+ examples: Eksempler
219
+ given: Gitt
220
+ when: Når
221
+ then: Så
222
+ and: Og
223
+ but: Men
224
+ "pl":
225
+ name: Polish
226
+ native: polski
227
+ encoding: UTF-8
228
+ feature: Właściwość
229
+ scenario: Scenariusz
230
+ given: Dane
231
+ when: Jeżeli
232
+ then: Wtedy
233
+ and: Oraz
234
+ but: Ale
235
+ "pt":
236
+ name: Portuguese
237
+ native: português
238
+ encoding: UTF-8
239
+ feature: Característica
240
+ scenario: Cenário
241
+ given: Dado
242
+ when: Quando
243
+ then: Então
244
+ and: E
245
+ but: Mas
246
+ "ro":
247
+ name: Romanian
248
+ native: română
249
+ encoding: UTF-8
250
+ feature: Functionalitate
251
+ scenario: Scenariu
252
+ given: Daca
253
+ when: Cand
254
+ then: Atunci
255
+ and: Si
256
+ but: Dar
257
+ "ro2":
258
+ name: Romanian (diacritical)
259
+ native: română (diacritical)
260
+ encoding: UTF-8
261
+ feature: Funcționalitate
262
+ scenario: Scenariu
263
+ given: Dacă
264
+ when: Când
265
+ then: Atunci
266
+ and: Și
267
+ but: Dar
268
+ "ru":
269
+ name: Russian
270
+ native: русский язык
271
+ encoding: UTF-8
272
+ feature: Функционал
273
+ scenario: Сценарий
274
+ given: Сначала
275
+ when: Если
276
+ then: То
277
+ and: И
278
+ but: Но
279
+ "se":
280
+ name: Swedish
281
+ native: Svenska
282
+ encoding: UTF-8
283
+ feature: Egenskap
284
+ background: Bakgrund
285
+ scenario: Scenario
286
+ scenario_outline: Abstrakt Scenario
287
+ examples: Exempel
288
+ given: Givet
289
+ when: När
290
+ then: Så
291
+ and: Och
292
+ but: Men
293
+ "zh-CN":
294
+ name: Chinese simplified
295
+ native: 中文
296
+ encoding: UTF-8
297
+ feature: 功能
298
+ scenario: 场景
299
+ given: 假如
300
+ when: 当
301
+ then: 那么
302
+ and: 而且
303
+ but: 但是
304
+ "ko":
305
+ name: Korean
306
+ native: 한국어
307
+ encoding: UTF-8
308
+ feature: 기능
309
+ scenario: 예
310
+ given: 조건
311
+ when: 만일
312
+ then: 그러면
313
+ and: 그리고
314
+ but: 하지만