cucumber 0.8.6 → 0.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. data/.rspec +1 -1
  2. data/Caliper.yml +4 -0
  3. data/History.txt +1557 -0
  4. data/LICENSE +1 -1
  5. data/README.rdoc +26 -0
  6. data/Rakefile +51 -5
  7. data/VERSION.yml +5 -0
  8. data/bin/cucumber +1 -7
  9. data/cucumber.gemspec +77 -3
  10. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
  11. data/examples/i18n/he/features/step_definitons/calculator_steps.rb +1 -1
  12. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +7 -4
  13. data/examples/i18n/ro/features/suma.feature +11 -0
  14. data/examples/i18n/ru/features/division.feature +2 -2
  15. data/examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb +3 -3
  16. data/examples/sinatra/features/support/env.rb +5 -2
  17. data/examples/v8/features/fibonacci.feature +1 -1
  18. data/examples/watir/features/step_definitions/search_steps.rb +1 -1
  19. data/features/announce.feature +164 -0
  20. data/features/around_hooks.feature +232 -0
  21. data/features/background.feature +95 -284
  22. data/features/bug_371.feature +32 -0
  23. data/features/bug_464.feature +16 -0
  24. data/features/bug_475.feature +42 -0
  25. data/features/bug_585_tab_indentation.feature +22 -0
  26. data/features/bug_600.feature +67 -0
  27. data/features/call_steps_from_stepdefs.feature +154 -0
  28. data/features/cucumber_cli.feature +591 -0
  29. data/features/cucumber_cli_outlines.feature +117 -0
  30. data/features/custom_formatter.feature +73 -3
  31. data/features/default_snippets.feature +42 -0
  32. data/features/diffing.feature +25 -0
  33. data/features/drb_server_integration.feature +174 -0
  34. data/features/exception_in_after_block.feature +127 -0
  35. data/features/exception_in_after_step_block.feature +104 -0
  36. data/features/exception_in_before_block.feature +98 -0
  37. data/features/exclude_files.feature +20 -0
  38. data/features/expand.feature +60 -0
  39. data/features/html_formatter.feature +8 -0
  40. data/features/html_formatter/a.html +582 -0
  41. data/features/json_formatter.feature +245 -160
  42. data/features/junit_formatter.feature +88 -0
  43. data/features/language_from_header.feature +30 -0
  44. data/features/language_help.feature +78 -0
  45. data/features/listener_debugger_formatter.feature +42 -0
  46. data/features/multiline_names.feature +44 -0
  47. data/features/negative_tagged_hooks.feature +60 -0
  48. data/features/post_configuration_hook.feature +37 -0
  49. data/features/profiles.feature +126 -0
  50. data/features/rake_task.feature +152 -0
  51. data/features/report_called_undefined_steps.feature +34 -0
  52. data/features/rerun_formatter.feature +45 -0
  53. data/features/simplest.feature +11 -0
  54. data/features/snippet.feature +23 -0
  55. data/features/snippets_when_using_star_keyword.feature +36 -0
  56. data/features/step_definitions/cucumber_steps.rb +153 -7
  57. data/features/step_definitions/extra_steps.rb +2 -0
  58. data/features/step_definitions/simplest_steps.rb +3 -0
  59. data/features/step_definitions/wire_steps.rb +32 -0
  60. data/features/support/env.rb +140 -18
  61. data/features/support/env.rb.simplest +7 -0
  62. data/features/support/fake_wire_server.rb +77 -0
  63. data/features/table_diffing.feature +45 -0
  64. data/features/table_mapping.feature +34 -0
  65. data/features/tag_logic.feature +258 -0
  66. data/features/transform.feature +245 -0
  67. data/features/unicode_table.feature +35 -0
  68. data/features/usage_and_stepdefs_formatter.feature +169 -0
  69. data/features/wire_protocol.feature +332 -0
  70. data/features/wire_protocol_table_diffing.feature +119 -0
  71. data/features/wire_protocol_tags.feature +87 -0
  72. data/features/wire_protocol_timeouts.feature +63 -0
  73. data/features/work_in_progress.feature +156 -0
  74. data/fixtures/json/features/pystring.feature +8 -0
  75. data/fixtures/junit/features/pending.feature +1 -3
  76. data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +12 -0
  77. data/fixtures/self_test/features/background/background_with_name.feature +7 -0
  78. data/fixtures/self_test/features/background/failing_background.feature +12 -0
  79. data/fixtures/self_test/features/background/failing_background_after_success.feature +11 -0
  80. data/fixtures/self_test/features/background/multiline_args_background.feature +32 -0
  81. data/fixtures/self_test/features/background/passing_background.feature +10 -0
  82. data/fixtures/self_test/features/background/pending_background.feature +10 -0
  83. data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +16 -0
  84. data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +16 -0
  85. data/fixtures/self_test/features/support/env.rb +0 -8
  86. data/fixtures/tickets/features.html +1 -1
  87. data/gem_tasks/examples.rake +1 -1
  88. data/gem_tasks/features.rake +14 -0
  89. data/gem_tasks/sdoc.rake +12 -0
  90. data/lib/cucumber.rb +0 -12
  91. data/lib/cucumber/ast.rb +1 -1
  92. data/lib/cucumber/ast/background.rb +5 -21
  93. data/lib/cucumber/ast/examples.rb +4 -12
  94. data/lib/cucumber/ast/feature.rb +5 -13
  95. data/lib/cucumber/ast/feature_element.rb +4 -9
  96. data/lib/cucumber/ast/outline_table.rb +4 -4
  97. data/lib/cucumber/ast/py_string.rb +80 -0
  98. data/lib/cucumber/ast/scenario.rb +5 -7
  99. data/lib/cucumber/ast/scenario_outline.rb +15 -23
  100. data/lib/cucumber/ast/step.rb +0 -5
  101. data/lib/cucumber/ast/step_invocation.rb +15 -21
  102. data/lib/cucumber/ast/table.rb +8 -14
  103. data/lib/cucumber/ast/tree_walker.rb +48 -10
  104. data/lib/cucumber/cli/configuration.rb +8 -33
  105. data/lib/cucumber/cli/main.rb +35 -20
  106. data/lib/cucumber/cli/options.rb +7 -8
  107. data/lib/cucumber/cli/profile_loader.rb +0 -2
  108. data/lib/cucumber/core_ext/proc.rb +1 -2
  109. data/lib/cucumber/feature_file.rb +15 -47
  110. data/lib/cucumber/formatter/ansicolor.rb +5 -3
  111. data/lib/cucumber/formatter/color_io.rb +23 -0
  112. data/lib/cucumber/formatter/console.rb +23 -27
  113. data/lib/cucumber/formatter/cucumber.css +17 -34
  114. data/lib/cucumber/formatter/cucumber.sass +182 -173
  115. data/lib/cucumber/formatter/html.rb +11 -46
  116. data/lib/cucumber/formatter/io.rb +4 -2
  117. data/lib/cucumber/formatter/json.rb +152 -15
  118. data/lib/cucumber/formatter/json_pretty.rb +6 -5
  119. data/lib/cucumber/formatter/junit.rb +22 -28
  120. data/lib/cucumber/formatter/pdf.rb +6 -6
  121. data/lib/cucumber/formatter/pretty.rb +5 -5
  122. data/lib/cucumber/formatter/rerun.rb +11 -22
  123. data/lib/cucumber/formatter/tag_cloud.rb +35 -0
  124. data/lib/cucumber/formatter/unicode.rb +20 -41
  125. data/lib/cucumber/js_support/js_dsl.js +4 -4
  126. data/lib/cucumber/js_support/js_language.rb +5 -9
  127. data/lib/cucumber/js_support/js_snippets.rb +2 -2
  128. data/lib/cucumber/language_support.rb +2 -2
  129. data/lib/cucumber/parser/gherkin_builder.rb +30 -35
  130. data/lib/cucumber/platform.rb +8 -8
  131. data/lib/cucumber/py_support/py_language.rb +2 -2
  132. data/lib/cucumber/rake/task.rb +31 -74
  133. data/lib/cucumber/rb_support/rb_dsl.rb +0 -1
  134. data/lib/cucumber/rb_support/rb_language.rb +8 -10
  135. data/lib/cucumber/rb_support/rb_step_definition.rb +0 -8
  136. data/lib/cucumber/rb_support/rb_transform.rb +0 -17
  137. data/lib/cucumber/rb_support/rb_world.rb +18 -26
  138. data/lib/cucumber/rspec/doubles.rb +3 -3
  139. data/lib/cucumber/step_match.rb +2 -6
  140. data/lib/cucumber/step_mother.rb +427 -6
  141. data/lib/cucumber/wire_support/configuration.rb +1 -4
  142. data/lib/cucumber/wire_support/wire_language.rb +10 -3
  143. data/spec/cucumber/ast/background_spec.rb +6 -68
  144. data/spec/cucumber/ast/feature_factory.rb +4 -5
  145. data/spec/cucumber/ast/feature_spec.rb +4 -4
  146. data/spec/cucumber/ast/outline_table_spec.rb +1 -1
  147. data/spec/cucumber/ast/py_string_spec.rb +40 -0
  148. data/spec/cucumber/ast/scenario_outline_spec.rb +11 -15
  149. data/spec/cucumber/ast/scenario_spec.rb +4 -4
  150. data/spec/cucumber/ast/step_spec.rb +3 -3
  151. data/spec/cucumber/ast/table_spec.rb +2 -38
  152. data/spec/cucumber/ast/tree_walker_spec.rb +2 -2
  153. data/spec/cucumber/broadcaster_spec.rb +1 -1
  154. data/spec/cucumber/cli/configuration_spec.rb +6 -32
  155. data/spec/cucumber/cli/drb_client_spec.rb +3 -2
  156. data/spec/cucumber/cli/main_spec.rb +43 -43
  157. data/spec/cucumber/cli/options_spec.rb +1 -28
  158. data/spec/cucumber/cli/profile_loader_spec.rb +1 -1
  159. data/spec/cucumber/core_ext/proc_spec.rb +1 -1
  160. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
  161. data/spec/cucumber/formatter/color_io_spec.rb +29 -0
  162. data/spec/cucumber/formatter/duration_spec.rb +1 -1
  163. data/spec/cucumber/formatter/html_spec.rb +5 -3
  164. data/spec/cucumber/formatter/junit_spec.rb +2 -16
  165. data/spec/cucumber/formatter/progress_spec.rb +1 -1
  166. data/spec/cucumber/formatter/spec_helper.rb +12 -11
  167. data/spec/cucumber/rb_support/rb_language_spec.rb +28 -241
  168. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +28 -33
  169. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
  170. data/spec/cucumber/step_match_spec.rb +9 -11
  171. data/spec/cucumber/step_mother_spec.rb +302 -0
  172. data/spec/cucumber/wire_support/configuration_spec.rb +1 -1
  173. data/spec/cucumber/wire_support/connection_spec.rb +1 -1
  174. data/spec/cucumber/wire_support/wire_exception_spec.rb +1 -1
  175. data/spec/cucumber/wire_support/wire_language_spec.rb +1 -1
  176. data/spec/cucumber/wire_support/wire_packet_spec.rb +1 -1
  177. data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
  178. data/spec/cucumber/world/pending_spec.rb +2 -2
  179. data/spec/spec_helper.rb +20 -13
  180. metadata +78 -4
@@ -5,17 +5,14 @@ require 'cucumber/formatter/ansicolor'
5
5
  $KCODE='u' unless Cucumber::RUBY_1_9
6
6
 
7
7
  if Cucumber::WINDOWS
8
- require 'iconv' unless Cucumber::RUBY_1_9
8
+ require 'iconv'
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()}"
12
14
  elsif `cmd /c chcp` =~ /(\d+)/
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
15
+ Cucumber::CODEPAGE = "cp#{$1.to_i}"
19
16
  else
20
17
  Cucumber::CODEPAGE = "cp1252"
21
18
  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.")
@@ -27,45 +24,27 @@ if Cucumber::WINDOWS
27
24
  o.instance_eval do
28
25
  alias cucumber_print print
29
26
  def 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
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)
47
35
  end
48
36
  end
49
37
 
50
38
  alias cucumber_puts puts
51
39
  def 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
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)
69
48
  end
70
49
  end
71
50
  end
@@ -1,15 +1,15 @@
1
1
  var CucumberJsDsl = {
2
2
  registerStepDefinition: function(regexp, func) {
3
3
  if(func == null) {
4
- jsLanguage.execute_step_definition(regexp);
4
+ jsLanguage.executeStepDefinition(regexp);
5
5
  }
6
6
  else{
7
- jsLanguage.add_step_definition(regexp, func);
7
+ jsLanguage.addStepDefinition(regexp, func);
8
8
  }
9
9
  },
10
10
 
11
11
  registerTransform: function(regexp, func) {
12
- jsLanguage.register_js_transform(regexp, func);
12
+ jsLanguage.registerJsTransform(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.register_js_hook(label, tag_expressions, hook_func);
43
+ jsLanguage.registerJsHook(label, tag_expressions, hook_func);
44
44
  }
45
45
  }
46
46
 
@@ -39,10 +39,6 @@ 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
-
46
42
  def arguments_from(step_name)
47
43
  matches = eval_js "#{@regexp}.exec('#{step_name}')"
48
44
  if matches
@@ -105,10 +101,10 @@ module Cucumber
105
101
  include LanguageSupport::LanguageMethods
106
102
  include JsSnippets
107
103
 
108
- def initialize(runtime)
104
+ def initialize(step_mother)
109
105
  @step_definitions = []
110
106
  @world = JsWorld.new
111
- @runtime = runtime
107
+ @step_mother = step_mother
112
108
 
113
109
  @world["jsLanguage"] = self
114
110
  @world.load(File.dirname(__FILE__) + '/js_dsl.js')
@@ -150,7 +146,7 @@ module Cucumber
150
146
 
151
147
  #TODO: support multiline arguments when calling steps from within steps
152
148
  def execute_step_definition(name, multiline_argument = nil)
153
- @runtime.step_match(name).invoke(multiline_argument)
149
+ @step_mother.step_match(name).invoke(multiline_argument)
154
150
  end
155
151
 
156
152
  def register_js_hook(phase, tag_expressions, js_function)
@@ -166,12 +162,12 @@ module Cucumber
166
162
  end
167
163
 
168
164
  def steps(steps_text, file_colon_line)
169
- @runtime.invoke_steps(steps_text, @language, file_colon_line)
165
+ @step_mother.invoke_steps(steps_text, @language, file_colon_line)
170
166
  end
171
167
 
172
168
  private
173
169
  def path_to_load_js_from
174
- paths = @runtime.features_paths
170
+ paths = @step_mother.options[:paths]
175
171
  if paths.empty?
176
172
  '' # Using rake
177
173
  else
@@ -4,7 +4,7 @@ module Cucumber
4
4
  PARAM_PATTERN = /"([^"]*)"/
5
5
  ESCAPED_PARAM_PATTERN = '"([^\\"]*)"'
6
6
 
7
- def snippet_text(code_keyword, step_name, multiline_arg_class)
7
+ def snippet_text(step_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
- "#{code_keyword}(/^#{escaped}$/, function(#{block_arg_string}){\n #{multiline_class_comment} //express the regexp above with the code you wish you had\n});"
23
+ "#{step_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 language support in Cucumber.
2
+ # This module defines the API for programming panguage 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,33 +13,28 @@ module Cucumber
13
13
  @feature || @multiline_arg
14
14
  end
15
15
 
16
- def feature(feature)
16
+ def feature(statement, uri)
17
17
  @feature = Ast::Feature.new(
18
18
  nil,
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,
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),
24
23
  []
25
24
  )
26
- @feature.gherkin_statement(feature)
27
- @feature
28
25
  end
29
26
 
30
- def background(background)
27
+ def background(statement)
31
28
  @background = Ast::Background.new(
32
- Ast::Comment.new(background.comments.map{|comment| comment.value}.join("\n")),
33
- background.line,
34
- background.keyword,
35
- background.name,
36
- background.description,
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),
37
33
  steps=[]
38
34
  )
39
35
  @feature.background = @background
40
36
  @background.feature = @feature
41
37
  @step_container = @background
42
- @background.gherkin_statement(background)
43
38
  end
44
39
 
45
40
  def scenario(statement)
@@ -49,14 +44,12 @@ module Cucumber
49
44
  Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
50
45
  statement.line,
51
46
  statement.keyword,
52
- statement.name,
53
- statement.description,
47
+ legacy_name_for(statement.name, statement.description),
54
48
  steps=[]
55
49
  )
56
50
  @feature.add_feature_element(scenario)
57
51
  @background.feature_elements << scenario if @background
58
52
  @step_container = scenario
59
- scenario.gherkin_statement(statement)
60
53
  end
61
54
 
62
55
  def scenario_outline(statement)
@@ -66,8 +59,7 @@ module Cucumber
66
59
  Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
67
60
  statement.line,
68
61
  statement.keyword,
69
- statement.name,
70
- statement.description,
62
+ legacy_name_for(statement.name, statement.description),
71
63
  steps=[],
72
64
  example_sections=[]
73
65
  )
@@ -77,28 +69,25 @@ module Cucumber
77
69
  @background.feature_elements << scenario_outline
78
70
  end
79
71
  @step_container = scenario_outline
80
- scenario_outline.gherkin_statement(statement)
81
72
  end
82
73
 
83
- def examples(examples)
74
+ def examples(statement, examples_rows)
84
75
  examples_fields = [
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)
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)
91
81
  ]
92
- @step_container.add_examples(examples_fields, examples)
82
+ @step_container.add_examples(examples_fields)
93
83
  end
94
84
 
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)
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)
99
88
  case(multiline_arg)
100
- when Gherkin::Formatter::Model::DocString
101
- @table_owner.multiline_arg = Ast::DocString.new(multiline_arg.value)
89
+ when Gherkin::Formatter::Model::PyString
90
+ @table_owner.multiline_arg = Ast::PyString.new(multiline_arg.value)
102
91
  when Array
103
92
  @table_owner.multiline_arg = Ast::Table.new(matrix(multiline_arg))
104
93
  end
@@ -114,6 +103,12 @@ module Cucumber
114
103
 
115
104
  private
116
105
 
106
+ def legacy_name_for(name, description)
107
+ s = name
108
+ s += "\n#{description}" if description != ""
109
+ s
110
+ end
111
+
117
112
  def matrix(gherkin_table)
118
113
  gherkin_table.map do |gherkin_row|
119
114
  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'
4
5
 
5
6
  module Cucumber
6
- unless defined?(Cucumber::VERSION)
7
- VERSION = '0.10.7'
7
+ version = YAML.load_file(File.dirname(__FILE__) + '/../../VERSION.yml')
8
+ VERSION = [version[:major], version[:minor], version[:patch], version[:build]].compact.join('.')
8
9
  BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
9
10
  LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib')
10
11
  JRUBY = defined?(JRUBY_VERSION)
11
12
  IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == "ironruby"
12
- WINDOWS = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
13
- OS_X = RbConfig::CONFIG['host_os'] =~ /darwin/
13
+ WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
14
+ OS_X = Config::CONFIG['host_os'] =~ /darwin/
14
15
  WINDOWS_MRI = WINDOWS && !JRUBY && !IRONRUBY
15
16
  RAILS = defined?(Rails)
16
- RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
17
+ RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
17
18
  RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
18
19
  RUBY_1_8_7 = RUBY_VERSION =~ /^1\.8\.7/
19
20
 
20
21
  class << self
21
22
  attr_accessor :use_full_backtrace
22
23
 
23
- def file_mode(m, encoding="UTF-8") #:nodoc:
24
- RUBY_1_9 ? "#{m}:#{encoding}" : m
24
+ def file_mode(m) #:nodoc:
25
+ RUBY_1_9 ? "#{m}:UTF-8" : m
25
26
  end
26
27
  end
27
28
  self.use_full_backtrace = false
28
29
  end
29
- end
@@ -28,8 +28,8 @@ module Cucumber
28
28
  mod = import(py_file)
29
29
  end
30
30
 
31
- def snippet_text(code_keyword, step_name, multiline_arg_class)
32
- "python snippet: #{code_keyword}, #{step_name}"
31
+ def snippet_text(step_keyword, step_name, multiline_arg_class)
32
+ "python snippet: #{step_keyword}, #{step_name}"
33
33
  end
34
34
 
35
35
  def begin_scenario(scenario)
@@ -1,5 +1,4 @@
1
1
  require 'cucumber/platform'
2
- require 'gherkin/formatter/ansi_escapes'
3
2
 
4
3
  begin
5
4
  # Support Rake > 0.8.7
@@ -7,7 +6,6 @@ begin
7
6
  include Rake::DSL
8
7
  rescue LoadError
9
8
  end
10
-
11
9
  module Cucumber
12
10
  module Rake
13
11
  # Defines a Rake task for running features.
@@ -16,7 +14,7 @@ module Cucumber
16
14
  #
17
15
  # Cucumber::Rake::Task.new
18
16
  #
19
- # This will define a task named <tt>cucumber</tt> described as 'Run Cucumber features'.
17
+ # This will define a task named <tt>cucumber</tt> described as 'Run Cucumber features'.
20
18
  # It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
21
19
  #
22
20
  # To further configure the task, you can pass a block:
@@ -30,96 +28,68 @@ module Cucumber
30
28
  # Cucumber::Rake::Task.new do |t|
31
29
  # t.rcov = true
32
30
  # end
33
- #
31
+ #
34
32
  # See the attributes for additional configuration possibilities.
35
33
  class Task
36
- include Gherkin::Formatter::AnsiEscapes
37
-
38
34
  class InProcessCucumberRunner #:nodoc:
39
35
  attr_reader :args
40
-
36
+
41
37
  def initialize(libs, cucumber_opts, feature_files)
42
38
  raise "libs must be an Array when running in-process" unless Array === libs
43
39
  libs.reverse.each{|lib| $LOAD_PATH.unshift(lib)}
44
40
  @args = (
45
- cucumber_opts +
41
+ cucumber_opts +
46
42
  feature_files
47
43
  ).flatten.compact
48
44
  end
49
-
45
+
50
46
  def run
51
47
  require 'cucumber/cli/main'
52
48
  failure = Cucumber::Cli::Main.execute(args)
53
49
  raise "Cucumber failed" if failure
54
50
  end
55
51
  end
56
-
52
+
57
53
  class ForkedCucumberRunner #:nodoc:
58
-
59
- def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files)
60
- @libs = libs
61
- @cucumber_bin = cucumber_bin
62
- @cucumber_opts = cucumber_opts
63
- @bundler = bundler
64
- @feature_files = feature_files
54
+ attr_reader :args
55
+
56
+ def initialize(libs, cucumber_bin, cucumber_opts, feature_files)
57
+ @args = (
58
+ ['-I'] + load_path(libs) +
59
+ quoted_binary(cucumber_bin) +
60
+ cucumber_opts +
61
+ feature_files
62
+ ).flatten
65
63
  end
66
64
 
67
65
  def load_path(libs)
68
- ['"%s"' % @libs.join(File::PATH_SEPARATOR)]
66
+ ['"%s"' % libs.join(File::PATH_SEPARATOR)]
69
67
  end
70
68
 
71
69
  def quoted_binary(cucumber_bin)
72
70
  ['"%s"' % cucumber_bin]
73
71
  end
74
72
 
75
- def use_bundler
76
- @bundler.nil? ? File.exist?("./Gemfile") && gem_available?("bundler") : @bundler
77
- end
78
-
79
- def gem_available?(gemname)
80
- gem_available_new_rubygems?(gemname) || gem_available_old_rubygems?(gemname)
81
- end
82
-
83
- def gem_available_old_rubygems?(gemname)
84
- Gem.available?(gemname)
85
- end
86
-
87
- def gem_available_new_rubygems?(gemname)
88
- Gem::Specification.respond_to?(:find_all_by_name) && Gem::Specification.find_all_by_name(gemname).any?
89
- end
90
-
91
- def cmd
92
- if use_bundler
93
- [ Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'cucumber', @cucumber_opts,
94
- @feature_files ].flatten
95
- else
96
- [ Cucumber::RUBY_BINARY, '-I', load_path(@libs), quoted_binary(@cucumber_bin),
97
- @cucumber_opts, @feature_files ].flatten
98
- end
73
+ def runner
74
+ File.exist?("./Gemfile") ? ["bundle", "exec", RUBY] : [RUBY]
99
75
  end
100
76
 
101
77
  def run
102
- sh(cmd.join(" "))
78
+ sh((runner + args).join(" "))
103
79
  end
104
80
  end
105
81
 
106
82
  class RCovCucumberRunner < ForkedCucumberRunner #:nodoc:
107
-
108
- def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files, rcov_opts)
109
- super( libs, cucumber_bin, cucumber_opts, bundler, feature_files )
110
- @rcov_opts = rcov_opts
111
- end
112
-
113
- def cmd
114
- if use_bundler
115
- [Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'rcov', @rcov_opts,
116
- quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
117
- else
118
- [Cucumber::RUBY_BINARY, '-I', load_path(@libs), '-S', 'rcov', @rcov_opts,
119
- quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
120
- end
83
+ def initialize(libs, cucumber_bin, cucumber_opts, feature_files, rcov_opts)
84
+ @args = (
85
+ ['-I'] + load_path(libs) +
86
+ ['-S', 'rcov'] + rcov_opts +
87
+ quoted_binary(cucumber_bin) +
88
+ ['--'] +
89
+ cucumber_opts +
90
+ feature_files
91
+ ).flatten
121
92
  end
122
-
123
93
  end
124
94
 
125
95
  LIB = File.expand_path(File.dirname(__FILE__) + '/../..') #:nodoc:
@@ -140,12 +110,6 @@ module Cucumber
140
110
  # Run cucumber with RCov? Defaults to false. If you set this to
141
111
  # true, +fork+ is implicit.
142
112
  attr_accessor :rcov
143
- def rcov=(flag)
144
- if(flag && Cucumber::RUBY_1_9)
145
- raise failed + "RCov only works on Ruby 1.8.x. You may want to use SimpleCov: https://github.com/colszowka/simplecov" + reset
146
- end
147
- @rcov = flag
148
- end
149
113
 
150
114
  # Extra options to pass to rcov.
151
115
  # It's recommended to pass an Array, but if it's a String it will be #split by ' '.
@@ -159,17 +123,10 @@ module Cucumber
159
123
  # your load path and gems.
160
124
  attr_accessor :fork
161
125
 
162
- # Define what profile to be used. When used with cucumber_opts it is simply appended
126
+ # Define what profile to be used. When used with cucumber_opts it is simply appended
163
127
  # to it. Will be ignored when CUCUMBER_OPTS is used.
164
128
  attr_accessor :profile
165
129
 
166
- # Whether or not to run with bundler (bundle exec). Setting this to false may speed
167
- # up the execution. The default value is true if Bundler is installed and you have
168
- # a Gemfile, false otherwise.
169
- #
170
- # Note that this attribute has no effect if you don't run in forked mode.
171
- attr_accessor :bundler
172
-
173
130
  # Define Cucumber Rake task
174
131
  def initialize(task_name = "cucumber", desc = "Run Cucumber features")
175
132
  @task_name, @desc = task_name, desc
@@ -195,9 +152,9 @@ module Cucumber
195
152
  def runner(task_args = nil) #:nodoc:
196
153
  cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile]
197
154
  if(@rcov)
198
- RCovCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files, rcov_opts)
155
+ RCovCucumberRunner.new(libs, binary, cucumber_opts, feature_files, rcov_opts)
199
156
  elsif(@fork)
200
- ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files)
157
+ ForkedCucumberRunner.new(libs, binary, cucumber_opts, feature_files)
201
158
  else
202
159
  InProcessCucumberRunner.new(libs, cucumber_opts, feature_files)
203
160
  end