cucumber 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/.rspec +1 -1
  2. data/LICENSE +1 -1
  3. data/Rakefile +5 -51
  4. data/bin/cucumber +7 -1
  5. data/cucumber.gemspec +463 -679
  6. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
  7. data/examples/i18n/he/features/step_definitons/calculator_steps.rb +1 -1
  8. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +4 -7
  9. data/examples/i18n/ru/features/division.feature +2 -2
  10. data/examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb +3 -3
  11. data/examples/sinatra/features/support/env.rb +2 -5
  12. data/examples/v8/features/fibonacci.feature +1 -1
  13. data/examples/watir/features/step_definitions/search_steps.rb +1 -1
  14. data/features/background.feature +284 -95
  15. data/features/custom_formatter.feature +3 -73
  16. data/features/json_formatter.feature +160 -245
  17. data/features/step_definitions/cucumber_steps.rb +7 -153
  18. data/features/support/env.rb +18 -140
  19. data/fixtures/junit/features/pending.feature +3 -1
  20. data/fixtures/self_test/features/support/env.rb +8 -0
  21. data/fixtures/tickets/features.html +1 -1
  22. data/gem_tasks/examples.rake +1 -1
  23. data/lib/cucumber.rb +12 -0
  24. data/lib/cucumber/ast.rb +1 -1
  25. data/lib/cucumber/ast/background.rb +21 -5
  26. data/lib/cucumber/ast/examples.rb +12 -4
  27. data/lib/cucumber/ast/feature.rb +13 -5
  28. data/lib/cucumber/ast/feature_element.rb +9 -4
  29. data/lib/cucumber/ast/outline_table.rb +4 -4
  30. data/lib/cucumber/ast/scenario.rb +7 -5
  31. data/lib/cucumber/ast/scenario_outline.rb +23 -15
  32. data/lib/cucumber/ast/step.rb +5 -0
  33. data/lib/cucumber/ast/step_invocation.rb +21 -15
  34. data/lib/cucumber/ast/table.rb +14 -8
  35. data/lib/cucumber/ast/tree_walker.rb +10 -48
  36. data/lib/cucumber/cli/configuration.rb +33 -8
  37. data/lib/cucumber/cli/main.rb +20 -35
  38. data/lib/cucumber/cli/options.rb +8 -7
  39. data/lib/cucumber/cli/profile_loader.rb +2 -0
  40. data/lib/cucumber/core_ext/proc.rb +2 -1
  41. data/lib/cucumber/feature_file.rb +47 -15
  42. data/lib/cucumber/formatter/ansicolor.rb +3 -5
  43. data/lib/cucumber/formatter/console.rb +27 -23
  44. data/lib/cucumber/formatter/cucumber.css +34 -17
  45. data/lib/cucumber/formatter/cucumber.sass +173 -182
  46. data/lib/cucumber/formatter/html.rb +46 -11
  47. data/lib/cucumber/formatter/io.rb +2 -4
  48. data/lib/cucumber/formatter/json.rb +15 -152
  49. data/lib/cucumber/formatter/json_pretty.rb +5 -6
  50. data/lib/cucumber/formatter/junit.rb +28 -22
  51. data/lib/cucumber/formatter/pdf.rb +6 -6
  52. data/lib/cucumber/formatter/pretty.rb +5 -5
  53. data/lib/cucumber/formatter/rerun.rb +22 -11
  54. data/lib/cucumber/formatter/unicode.rb +41 -20
  55. data/lib/cucumber/js_support/js_dsl.js +4 -4
  56. data/lib/cucumber/js_support/js_language.rb +9 -5
  57. data/lib/cucumber/js_support/js_snippets.rb +2 -2
  58. data/lib/cucumber/language_support.rb +2 -2
  59. data/lib/cucumber/parser/gherkin_builder.rb +35 -30
  60. data/lib/cucumber/platform.rb +8 -8
  61. data/lib/cucumber/py_support/py_language.rb +2 -2
  62. data/lib/cucumber/rake/task.rb +80 -31
  63. data/lib/cucumber/rb_support/rb_dsl.rb +1 -0
  64. data/lib/cucumber/rb_support/rb_language.rb +10 -8
  65. data/lib/cucumber/rb_support/rb_step_definition.rb +8 -0
  66. data/lib/cucumber/rb_support/rb_transform.rb +17 -0
  67. data/lib/cucumber/rb_support/rb_world.rb +26 -18
  68. data/lib/cucumber/rspec/doubles.rb +3 -3
  69. data/lib/cucumber/step_match.rb +6 -2
  70. data/lib/cucumber/step_mother.rb +6 -427
  71. data/lib/cucumber/wire_support/configuration.rb +4 -1
  72. data/lib/cucumber/wire_support/wire_language.rb +3 -10
  73. data/spec/cucumber/ast/background_spec.rb +68 -6
  74. data/spec/cucumber/ast/feature_factory.rb +5 -4
  75. data/spec/cucumber/ast/feature_spec.rb +4 -4
  76. data/spec/cucumber/ast/outline_table_spec.rb +1 -1
  77. data/spec/cucumber/ast/scenario_outline_spec.rb +15 -11
  78. data/spec/cucumber/ast/scenario_spec.rb +4 -4
  79. data/spec/cucumber/ast/step_spec.rb +3 -3
  80. data/spec/cucumber/ast/table_spec.rb +38 -2
  81. data/spec/cucumber/ast/tree_walker_spec.rb +2 -2
  82. data/spec/cucumber/broadcaster_spec.rb +1 -1
  83. data/spec/cucumber/cli/configuration_spec.rb +32 -6
  84. data/spec/cucumber/cli/drb_client_spec.rb +2 -3
  85. data/spec/cucumber/cli/main_spec.rb +43 -43
  86. data/spec/cucumber/cli/options_spec.rb +28 -1
  87. data/spec/cucumber/cli/profile_loader_spec.rb +1 -1
  88. data/spec/cucumber/core_ext/proc_spec.rb +1 -1
  89. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
  90. data/spec/cucumber/formatter/duration_spec.rb +1 -1
  91. data/spec/cucumber/formatter/html_spec.rb +3 -5
  92. data/spec/cucumber/formatter/junit_spec.rb +16 -2
  93. data/spec/cucumber/formatter/progress_spec.rb +1 -1
  94. data/spec/cucumber/formatter/spec_helper.rb +11 -12
  95. data/spec/cucumber/rb_support/rb_language_spec.rb +241 -28
  96. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +33 -28
  97. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
  98. data/spec/cucumber/step_match_spec.rb +11 -9
  99. data/spec/cucumber/wire_support/configuration_spec.rb +1 -1
  100. data/spec/cucumber/wire_support/connection_spec.rb +1 -1
  101. data/spec/cucumber/wire_support/wire_exception_spec.rb +1 -1
  102. data/spec/cucumber/wire_support/wire_language_spec.rb +1 -1
  103. data/spec/cucumber/wire_support/wire_packet_spec.rb +1 -1
  104. data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
  105. data/spec/cucumber/world/pending_spec.rb +2 -2
  106. data/spec/spec_helper.rb +13 -20
  107. metadata +11 -222
  108. data/.gitignore +0 -20
  109. data/Caliper.yml +0 -4
  110. data/History.txt +0 -1552
  111. data/README.rdoc +0 -26
  112. data/VERSION.yml +0 -5
  113. data/examples/i18n/ro/features/suma.feature +0 -11
  114. data/features/announce.feature +0 -164
  115. data/features/around_hooks.feature +0 -232
  116. data/features/bug_371.feature +0 -32
  117. data/features/bug_464.feature +0 -16
  118. data/features/bug_475.feature +0 -42
  119. data/features/bug_585_tab_indentation.feature +0 -22
  120. data/features/bug_600.feature +0 -67
  121. data/features/call_steps_from_stepdefs.feature +0 -154
  122. data/features/cucumber_cli.feature +0 -591
  123. data/features/cucumber_cli_outlines.feature +0 -117
  124. data/features/default_snippets.feature +0 -42
  125. data/features/diffing.feature +0 -25
  126. data/features/drb_server_integration.feature +0 -174
  127. data/features/exception_in_after_block.feature +0 -127
  128. data/features/exception_in_after_step_block.feature +0 -104
  129. data/features/exception_in_before_block.feature +0 -98
  130. data/features/exclude_files.feature +0 -20
  131. data/features/expand.feature +0 -60
  132. data/features/html_formatter.feature +0 -8
  133. data/features/html_formatter/a.html +0 -582
  134. data/features/junit_formatter.feature +0 -88
  135. data/features/language_from_header.feature +0 -30
  136. data/features/language_help.feature +0 -78
  137. data/features/listener_debugger_formatter.feature +0 -42
  138. data/features/multiline_names.feature +0 -44
  139. data/features/negative_tagged_hooks.feature +0 -60
  140. data/features/post_configuration_hook.feature +0 -37
  141. data/features/profiles.feature +0 -126
  142. data/features/rake_task.feature +0 -152
  143. data/features/report_called_undefined_steps.feature +0 -34
  144. data/features/rerun_formatter.feature +0 -45
  145. data/features/simplest.feature +0 -11
  146. data/features/snippet.feature +0 -23
  147. data/features/snippets_when_using_star_keyword.feature +0 -36
  148. data/features/step_definitions/extra_steps.rb +0 -2
  149. data/features/step_definitions/simplest_steps.rb +0 -3
  150. data/features/step_definitions/wire_steps.rb +0 -32
  151. data/features/support/env.rb.simplest +0 -7
  152. data/features/support/fake_wire_server.rb +0 -77
  153. data/features/table_diffing.feature +0 -45
  154. data/features/table_mapping.feature +0 -34
  155. data/features/tag_logic.feature +0 -258
  156. data/features/transform.feature +0 -245
  157. data/features/unicode_table.feature +0 -35
  158. data/features/usage_and_stepdefs_formatter.feature +0 -169
  159. data/features/wire_protocol.feature +0 -332
  160. data/features/wire_protocol_table_diffing.feature +0 -119
  161. data/features/wire_protocol_tags.feature +0 -87
  162. data/features/wire_protocol_timeouts.feature +0 -63
  163. data/features/work_in_progress.feature +0 -156
  164. data/fixtures/json/features/pystring.feature +0 -8
  165. data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +0 -12
  166. data/fixtures/self_test/features/background/background_with_name.feature +0 -7
  167. data/fixtures/self_test/features/background/failing_background.feature +0 -12
  168. data/fixtures/self_test/features/background/failing_background_after_success.feature +0 -11
  169. data/fixtures/self_test/features/background/multiline_args_background.feature +0 -32
  170. data/fixtures/self_test/features/background/passing_background.feature +0 -10
  171. data/fixtures/self_test/features/background/pending_background.feature +0 -10
  172. data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +0 -16
  173. data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +0 -16
  174. data/gem_tasks/features.rake +0 -14
  175. data/gem_tasks/sdoc.rake +0 -12
  176. data/lib/cucumber/ast/py_string.rb +0 -80
  177. data/lib/cucumber/formatter/color_io.rb +0 -23
  178. data/lib/cucumber/formatter/tag_cloud.rb +0 -35
  179. data/spec/cucumber/ast/py_string_spec.rb +0 -40
  180. data/spec/cucumber/formatter/color_io_spec.rb +0 -29
  181. data/spec/cucumber/step_mother_spec.rb +0 -302
@@ -25,7 +25,7 @@ module Cucumber
25
25
  @exceptions = []
26
26
  @indent = 0
27
27
  @prefixes = options[:prefixes] || {}
28
- @delayed_announcements = []
28
+ @delayed_messages = []
29
29
  end
30
30
 
31
31
  def after_features(features)
@@ -101,7 +101,7 @@ module Cucumber
101
101
  end
102
102
 
103
103
  def examples_name(keyword, name)
104
- puts unless @visiting_first_example_name
104
+ @io.puts unless @visiting_first_example_name
105
105
  @visiting_first_example_name = false
106
106
  names = name.strip.empty? ? [name.strip] : name.split("\n")
107
107
  @io.puts(" #{keyword}: #{names[0]}")
@@ -150,10 +150,10 @@ module Cucumber
150
150
  source_indent = nil unless @options[:source]
151
151
  name_to_report = format_step(keyword, step_match, status, source_indent)
152
152
  @io.puts(name_to_report.indent(@scenario_indent + 2))
153
- print_announcements
153
+ print_messages
154
154
  end
155
155
 
156
- def py_string(string)
156
+ def doc_string(string)
157
157
  return if @hide_this_step
158
158
  s = %{"""\n#{string}\n"""}.indent(@indent)
159
159
  s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}.join("\n")
@@ -184,7 +184,7 @@ module Cucumber
184
184
 
185
185
  def after_table_row(table_row)
186
186
  return if !@table || @hide_this_step
187
- print_table_row_announcements
187
+ print_table_row_messages
188
188
  @io.puts
189
189
  if table_row.exception && !@exceptions.include?(table_row.exception)
190
190
  print_exception(table_row.exception, table_row.status, @indent)
@@ -21,17 +21,21 @@ module Cucumber
21
21
  @file_names = []
22
22
  @file_colon_lines = Hash.new{|h,k| h[k] = []}
23
23
  end
24
-
25
- # features() is never executed at all... ?
26
- def after_features(features)
27
- files = @file_names.uniq.map do |file|
28
- lines = @file_colon_lines[file]
29
- "#{file}:#{lines.join(':')}"
24
+
25
+ def before_feature(*)
26
+ @lines = []
27
+ @file = nil
28
+ end
29
+
30
+ def after_feature(*)
31
+ after_first_time do
32
+ @io.print ' '
30
33
  end
31
- @io.puts files.join(' ')
32
-
33
- # Flusing output to rerun tempfile here...
34
+ @io.print "#{@file}:#{@lines.join(':')}"
34
35
  @io.flush
36
+ end
37
+
38
+ def after_features(features)
35
39
  @io.close
36
40
  end
37
41
 
@@ -42,14 +46,21 @@ module Cucumber
42
46
  def after_feature_element(feature_element)
43
47
  if @rerun
44
48
  file, line = *feature_element.file_colon_line.split(':')
45
- @file_colon_lines[file] << line
46
- @file_names << file
49
+ @lines << line
50
+ @file = file
47
51
  end
48
52
  end
49
53
 
50
54
  def step_name(keyword, step_match, status, source_indent, background)
51
55
  @rerun = true if [:failed, :pending, :undefined].index(status)
52
56
  end
57
+
58
+ private
59
+
60
+ def after_first_time
61
+ yield if @not_first_time
62
+ @not_first_time = true
63
+ end
53
64
  end
54
65
  end
55
66
  end
@@ -5,14 +5,17 @@ require 'cucumber/formatter/ansicolor'
5
5
  $KCODE='u' unless Cucumber::RUBY_1_9
6
6
 
7
7
  if Cucumber::WINDOWS
8
- require 'iconv'
8
+ require 'iconv' unless Cucumber::RUBY_1_9
9
9
 
10
10
  if ENV['CUCUMBER_OUTPUT_ENCODING']
11
11
  Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']
12
- elsif Cucumber::WINDOWS_MRI
13
- Cucumber::CODEPAGE = "cp#{Win32::Console::OutputCP()}"
14
12
  elsif `cmd /c chcp` =~ /(\d+)/
15
- Cucumber::CODEPAGE = "cp#{$1.to_i}"
13
+ if [65000, 65001].include? $1.to_i
14
+ Cucumber::CODEPAGE = 'UTF-8'
15
+ ENV['ANSICON_API'] = 'ruby'
16
+ else
17
+ Cucumber::CODEPAGE = "cp#{$1.to_i}"
18
+ end
16
19
  else
17
20
  Cucumber::CODEPAGE = "cp1252"
18
21
  STDERR.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")
@@ -24,27 +27,45 @@ if Cucumber::WINDOWS
24
27
  o.instance_eval do
25
28
  alias cucumber_print print
26
29
  def print(*a)
27
- begin
28
- cucumber_print(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
29
- rescue Iconv::InvalidEncoding => e
30
- STDERR.cucumber_puts("WARNING: #{e.message}")
31
- cucumber_print(*a)
32
- rescue Iconv::IllegalSequence => e
33
- STDERR.cucumber_puts("WARNING: #{e.message}")
34
- cucumber_print(*a)
30
+ if Cucumber::RUBY_1_9
31
+ begin
32
+ cucumber_print(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})
33
+ rescue Encoding::UndefinedConversionError => e
34
+ STDERR.cucumber_puts("WARNING: #{e.message}")
35
+ cucumber_print(*a)
36
+ end
37
+ else
38
+ begin
39
+ cucumber_print(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
40
+ rescue Iconv::InvalidEncoding => e
41
+ STDERR.cucumber_puts("WARNING: #{e.message}")
42
+ cucumber_print(*a)
43
+ rescue Iconv::IllegalSequence => e
44
+ STDERR.cucumber_puts("WARNING: #{e.message}")
45
+ cucumber_print(*a)
46
+ end
35
47
  end
36
48
  end
37
49
 
38
50
  alias cucumber_puts puts
39
51
  def puts(*a)
40
- begin
41
- cucumber_puts(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
42
- rescue Iconv::InvalidEncoding => e
43
- STDERR.cucumber_print("WARNING: #{e.message}")
44
- cucumber_print(*a)
45
- rescue Iconv::IllegalSequence => e
46
- STDERR.cucumber_puts("WARNING: #{e.message}")
47
- cucumber_puts(*a)
52
+ if Cucumber::RUBY_1_9
53
+ begin
54
+ cucumber_puts(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})
55
+ rescue Encoding::UndefinedConversionError => e
56
+ STDERR.cucumber_puts("WARNING: #{e.message}")
57
+ cucumber_puts(*a)
58
+ end
59
+ else
60
+ begin
61
+ cucumber_puts(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
62
+ rescue Iconv::InvalidEncoding => e
63
+ STDERR.cucumber_print("WARNING: #{e.message}")
64
+ cucumber_print(*a)
65
+ rescue Iconv::IllegalSequence => e
66
+ STDERR.cucumber_puts("WARNING: #{e.message}")
67
+ cucumber_puts(*a)
68
+ end
48
69
  end
49
70
  end
50
71
  end
@@ -1,15 +1,15 @@
1
1
  var CucumberJsDsl = {
2
2
  registerStepDefinition: function(regexp, func) {
3
3
  if(func == null) {
4
- jsLanguage.executeStepDefinition(regexp);
4
+ jsLanguage.execute_step_definition(regexp);
5
5
  }
6
6
  else{
7
- jsLanguage.addStepDefinition(regexp, func);
7
+ jsLanguage.add_step_definition(regexp, func);
8
8
  }
9
9
  },
10
10
 
11
11
  registerTransform: function(regexp, func) {
12
- jsLanguage.registerJsTransform(regexp, func);
12
+ jsLanguage.register_js_transform(regexp, func);
13
13
  },
14
14
 
15
15
  beforeHook: function(tag_expressions_or_func, func) {
@@ -40,7 +40,7 @@ var CucumberJsDsl = {
40
40
  var hook_func = tag_expressions_or_func;
41
41
  var tag_expressions = [];
42
42
  }
43
- jsLanguage.registerJsHook(label, tag_expressions, hook_func);
43
+ jsLanguage.register_js_hook(label, tag_expressions, hook_func);
44
44
  }
45
45
  }
46
46
 
@@ -39,6 +39,10 @@ module Cucumber
39
39
  @js_language.current_world.execute(@js_function, args)
40
40
  end
41
41
 
42
+ def regexp_source
43
+ @regexp.inspect
44
+ end
45
+
42
46
  def arguments_from(step_name)
43
47
  matches = eval_js "#{@regexp}.exec('#{step_name}')"
44
48
  if matches
@@ -101,10 +105,10 @@ module Cucumber
101
105
  include LanguageSupport::LanguageMethods
102
106
  include JsSnippets
103
107
 
104
- def initialize(step_mother)
108
+ def initialize(runtime)
105
109
  @step_definitions = []
106
110
  @world = JsWorld.new
107
- @step_mother = step_mother
111
+ @runtime = runtime
108
112
 
109
113
  @world["jsLanguage"] = self
110
114
  @world.load(File.dirname(__FILE__) + '/js_dsl.js')
@@ -146,7 +150,7 @@ module Cucumber
146
150
 
147
151
  #TODO: support multiline arguments when calling steps from within steps
148
152
  def execute_step_definition(name, multiline_argument = nil)
149
- @step_mother.step_match(name).invoke(multiline_argument)
153
+ @runtime.step_match(name).invoke(multiline_argument)
150
154
  end
151
155
 
152
156
  def register_js_hook(phase, tag_expressions, js_function)
@@ -162,12 +166,12 @@ module Cucumber
162
166
  end
163
167
 
164
168
  def steps(steps_text, file_colon_line)
165
- @step_mother.invoke_steps(steps_text, @language, file_colon_line)
169
+ @runtime.invoke_steps(steps_text, @language, file_colon_line)
166
170
  end
167
171
 
168
172
  private
169
173
  def path_to_load_js_from
170
- paths = @step_mother.options[:paths]
174
+ paths = @runtime.features_paths
171
175
  if paths.empty?
172
176
  '' # Using rake
173
177
  else
@@ -4,7 +4,7 @@ module Cucumber
4
4
  PARAM_PATTERN = /"([^"]*)"/
5
5
  ESCAPED_PARAM_PATTERN = '"([^\\"]*)"'
6
6
 
7
- def snippet_text(step_keyword, step_name, multiline_arg_class)
7
+ def snippet_text(code_keyword, step_name, multiline_arg_class)
8
8
  escaped = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
9
9
  escaped = escaped.gsub(PARAM_PATTERN, ESCAPED_PARAM_PATTERN)
10
10
 
@@ -20,7 +20,7 @@ module Cucumber
20
20
  multiline_class_comment = "//#{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n"
21
21
  end
22
22
 
23
- "#{step_keyword}(/^#{escaped}$/, function(#{block_arg_string}){\n #{multiline_class_comment} //express the regexp above with the code you wish you had\n});"
23
+ "#{code_keyword}(/^#{escaped}$/, function(#{block_arg_string}){\n #{multiline_class_comment} //express the regexp above with the code you wish you had\n});"
24
24
  end
25
25
  end
26
26
  end
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
- # This module defines the API for programming panguage support in Cucumber.
2
+ # This module defines the API for programming language support in Cucumber.
3
3
  # While Cucumber itself is written in Ruby, any programming language can
4
4
  # be supported by implementing this API.
5
5
  #
@@ -27,4 +27,4 @@ module Cucumber
27
27
  #
28
28
  module LanguageSupport
29
29
  end
30
- end
30
+ end
@@ -13,28 +13,33 @@ module Cucumber
13
13
  @feature || @multiline_arg
14
14
  end
15
15
 
16
- def feature(statement, uri)
16
+ def feature(feature)
17
17
  @feature = Ast::Feature.new(
18
18
  nil,
19
- Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")),
20
- Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
21
- statement.keyword,
22
- legacy_name_for(statement.name, statement.description),
19
+ Ast::Comment.new(feature.comments.map{|comment| comment.value}.join("\n")),
20
+ Ast::Tags.new(nil, feature.tags.map{|tag| tag.name}),
21
+ feature.keyword,
22
+ feature.name.lstrip,
23
+ feature.description.rstrip,
23
24
  []
24
25
  )
26
+ @feature.gherkin_statement(feature)
27
+ @feature
25
28
  end
26
29
 
27
- def background(statement)
30
+ def background(background)
28
31
  @background = Ast::Background.new(
29
- Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")),
30
- statement.line,
31
- statement.keyword,
32
- legacy_name_for(statement.name, statement.description),
32
+ Ast::Comment.new(background.comments.map{|comment| comment.value}.join("\n")),
33
+ background.line,
34
+ background.keyword,
35
+ background.name,
36
+ background.description,
33
37
  steps=[]
34
38
  )
35
39
  @feature.background = @background
36
40
  @background.feature = @feature
37
41
  @step_container = @background
42
+ @background.gherkin_statement(background)
38
43
  end
39
44
 
40
45
  def scenario(statement)
@@ -44,12 +49,14 @@ module Cucumber
44
49
  Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
45
50
  statement.line,
46
51
  statement.keyword,
47
- legacy_name_for(statement.name, statement.description),
52
+ statement.name,
53
+ statement.description,
48
54
  steps=[]
49
55
  )
50
56
  @feature.add_feature_element(scenario)
51
57
  @background.feature_elements << scenario if @background
52
58
  @step_container = scenario
59
+ scenario.gherkin_statement(statement)
53
60
  end
54
61
 
55
62
  def scenario_outline(statement)
@@ -59,7 +66,8 @@ module Cucumber
59
66
  Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
60
67
  statement.line,
61
68
  statement.keyword,
62
- legacy_name_for(statement.name, statement.description),
69
+ statement.name,
70
+ statement.description,
63
71
  steps=[],
64
72
  example_sections=[]
65
73
  )
@@ -69,25 +77,28 @@ module Cucumber
69
77
  @background.feature_elements << scenario_outline
70
78
  end
71
79
  @step_container = scenario_outline
80
+ scenario_outline.gherkin_statement(statement)
72
81
  end
73
82
 
74
- def examples(statement, examples_rows)
83
+ def examples(examples)
75
84
  examples_fields = [
76
- Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")),
77
- statement.line,
78
- statement.keyword,
79
- legacy_name_for(statement.name, statement.description),
80
- matrix(examples_rows)
85
+ Ast::Comment.new(examples.comments.map{|comment| comment.value}.join("\n")),
86
+ examples.line,
87
+ examples.keyword,
88
+ examples.name,
89
+ examples.description,
90
+ matrix(examples.rows)
81
91
  ]
82
- @step_container.add_examples(examples_fields)
92
+ @step_container.add_examples(examples_fields, examples)
83
93
  end
84
94
 
85
- def step(statement, multiline_arg, result)
86
- @table_owner = Ast::Step.new(statement.line, statement.keyword, statement.name)
87
- multiline_arg = rubify(multiline_arg)
95
+ def step(step)
96
+ @table_owner = Ast::Step.new(step.line, step.keyword, step.name)
97
+ @table_owner.gherkin_statement(step)
98
+ multiline_arg = rubify(step.multiline_arg)
88
99
  case(multiline_arg)
89
- when Gherkin::Formatter::Model::PyString
90
- @table_owner.multiline_arg = Ast::PyString.new(multiline_arg.value)
100
+ when Gherkin::Formatter::Model::DocString
101
+ @table_owner.multiline_arg = Ast::DocString.new(multiline_arg.value)
91
102
  when Array
92
103
  @table_owner.multiline_arg = Ast::Table.new(matrix(multiline_arg))
93
104
  end
@@ -103,12 +114,6 @@ module Cucumber
103
114
 
104
115
  private
105
116
 
106
- def legacy_name_for(name, description)
107
- s = name
108
- s += "\n#{description}" if description != ""
109
- s
110
- end
111
-
112
117
  def matrix(gherkin_table)
113
118
  gherkin_table.map do |gherkin_row|
114
119
  row = gherkin_row.cells
@@ -1,29 +1,29 @@
1
1
  # Detect the platform we're running on so we can tweak behaviour
2
2
  # in various places.
3
3
  require 'rbconfig'
4
- require 'yaml'
5
4
 
6
5
  module Cucumber
7
- version = YAML.load_file(File.dirname(__FILE__) + '/../../VERSION.yml')
8
- VERSION = [version[:major], version[:minor], version[:patch], version[:build]].compact.join('.')
6
+ unless defined?(Cucumber::VERSION)
7
+ VERSION = '0.10.7'
9
8
  BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
10
9
  LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib')
11
10
  JRUBY = defined?(JRUBY_VERSION)
12
11
  IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == "ironruby"
13
- WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
14
- OS_X = Config::CONFIG['host_os'] =~ /darwin/
12
+ WINDOWS = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
13
+ OS_X = RbConfig::CONFIG['host_os'] =~ /darwin/
15
14
  WINDOWS_MRI = WINDOWS && !JRUBY && !IRONRUBY
16
15
  RAILS = defined?(Rails)
17
- RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
16
+ RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
18
17
  RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
19
18
  RUBY_1_8_7 = RUBY_VERSION =~ /^1\.8\.7/
20
19
 
21
20
  class << self
22
21
  attr_accessor :use_full_backtrace
23
22
 
24
- def file_mode(m) #:nodoc:
25
- RUBY_1_9 ? "#{m}:UTF-8" : m
23
+ def file_mode(m, encoding="UTF-8") #:nodoc:
24
+ RUBY_1_9 ? "#{m}:#{encoding}" : m
26
25
  end
27
26
  end
28
27
  self.use_full_backtrace = false
29
28
  end
29
+ end
@@ -28,8 +28,8 @@ module Cucumber
28
28
  mod = import(py_file)
29
29
  end
30
30
 
31
- def snippet_text(step_keyword, step_name, multiline_arg_class)
32
- "python snippet: #{step_keyword}, #{step_name}"
31
+ def snippet_text(code_keyword, step_name, multiline_arg_class)
32
+ "python snippet: #{code_keyword}, #{step_name}"
33
33
  end
34
34
 
35
35
  def begin_scenario(scenario)