cucumber 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -2
  3. data/CONTRIBUTING.md +1 -0
  4. data/README.md +6 -7
  5. data/lib/autotest/cucumber.rb +1 -0
  6. data/lib/autotest/cucumber_mixin.rb +1 -0
  7. data/lib/autotest/cucumber_rails.rb +1 -0
  8. data/lib/autotest/cucumber_rails_rspec.rb +1 -0
  9. data/lib/autotest/cucumber_rails_rspec2.rb +1 -0
  10. data/lib/autotest/cucumber_rspec.rb +1 -0
  11. data/lib/autotest/cucumber_rspec2.rb +1 -0
  12. data/lib/autotest/discover.rb +1 -0
  13. data/lib/cucumber.rb +1 -0
  14. data/lib/cucumber/cli/configuration.rb +1 -0
  15. data/lib/cucumber/cli/main.rb +2 -2
  16. data/lib/cucumber/cli/options.rb +42 -40
  17. data/lib/cucumber/cli/profile_loader.rb +5 -7
  18. data/lib/cucumber/cli/rerun_file.rb +1 -0
  19. data/lib/cucumber/configuration.rb +1 -0
  20. data/lib/cucumber/constantize.rb +6 -5
  21. data/lib/cucumber/core_ext/string.rb +1 -0
  22. data/lib/cucumber/deprecate.rb +1 -1
  23. data/lib/cucumber/encoding.rb +2 -1
  24. data/lib/cucumber/errors.rb +1 -0
  25. data/lib/cucumber/events.rb +1 -1
  26. data/lib/cucumber/events/gherkin_source_read.rb +1 -4
  27. data/lib/cucumber/events/step_activated.rb +4 -5
  28. data/lib/cucumber/events/step_definition_registered.rb +4 -8
  29. data/lib/cucumber/events/test_case_finished.rb +0 -4
  30. data/lib/cucumber/events/test_case_started.rb +0 -4
  31. data/lib/cucumber/events/test_run_finished.rb +2 -3
  32. data/lib/cucumber/events/test_run_started.rb +2 -4
  33. data/lib/cucumber/events/test_step_finished.rb +0 -4
  34. data/lib/cucumber/events/test_step_started.rb +1 -5
  35. data/lib/cucumber/file_specs.rb +2 -1
  36. data/lib/cucumber/filters.rb +1 -0
  37. data/lib/cucumber/filters/activate_steps.rb +1 -1
  38. data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
  39. data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
  40. data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
  41. data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
  42. data/lib/cucumber/filters/broadcast_test_run_started_event.rb +2 -1
  43. data/lib/cucumber/filters/gated_receiver.rb +1 -2
  44. data/lib/cucumber/filters/prepare_world.rb +2 -5
  45. data/lib/cucumber/filters/quit.rb +2 -3
  46. data/lib/cucumber/filters/randomizer.rb +6 -7
  47. data/lib/cucumber/filters/retry.rb +2 -2
  48. data/lib/cucumber/filters/tag_limits.rb +2 -2
  49. data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -2
  50. data/lib/cucumber/filters/tag_limits/verifier.rb +1 -2
  51. data/lib/cucumber/formatter/ansicolor.rb +13 -12
  52. data/lib/cucumber/formatter/backtrace_filter.rb +1 -2
  53. data/lib/cucumber/formatter/console.rb +10 -11
  54. data/lib/cucumber/formatter/console_counts.rb +4 -4
  55. data/lib/cucumber/formatter/console_issues.rb +3 -3
  56. data/lib/cucumber/formatter/duration.rb +1 -0
  57. data/lib/cucumber/formatter/duration_extractor.rb +1 -1
  58. data/lib/cucumber/formatter/fail_fast.rb +9 -6
  59. data/lib/cucumber/formatter/fanout.rb +1 -3
  60. data/lib/cucumber/formatter/hook_query_visitor.rb +1 -0
  61. data/lib/cucumber/formatter/html.rb +27 -31
  62. data/lib/cucumber/formatter/html_builder.rb +2 -1
  63. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -2
  64. data/lib/cucumber/formatter/interceptor.rb +18 -5
  65. data/lib/cucumber/formatter/io.rb +1 -0
  66. data/lib/cucumber/formatter/json.rb +2 -1
  67. data/lib/cucumber/formatter/json_pretty.rb +1 -0
  68. data/lib/cucumber/formatter/junit.rb +16 -15
  69. data/lib/cucumber/formatter/pretty.rb +3 -2
  70. data/lib/cucumber/formatter/progress.rb +3 -2
  71. data/lib/cucumber/formatter/rerun.rb +1 -0
  72. data/lib/cucumber/formatter/stepdefs.rb +1 -0
  73. data/lib/cucumber/formatter/steps.rb +2 -2
  74. data/lib/cucumber/formatter/summary.rb +1 -1
  75. data/lib/cucumber/formatter/unicode.rb +2 -2
  76. data/lib/cucumber/formatter/usage.rb +21 -18
  77. data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
  78. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +86 -85
  79. data/lib/cucumber/gherkin/formatter/escaping.rb +13 -12
  80. data/lib/cucumber/gherkin/i18n.rb +1 -0
  81. data/lib/cucumber/gherkin/steps_parser.rb +1 -0
  82. data/lib/cucumber/glue/dsl.rb +1 -0
  83. data/lib/cucumber/glue/hook.rb +1 -0
  84. data/lib/cucumber/glue/invoke_in_world.rb +3 -3
  85. data/lib/cucumber/glue/proto_world.rb +8 -9
  86. data/lib/cucumber/glue/registry_and_more.rb +13 -12
  87. data/lib/cucumber/glue/snippet.rb +1 -5
  88. data/lib/cucumber/glue/step_definition.rb +9 -9
  89. data/lib/cucumber/glue/world_factory.rb +0 -2
  90. data/lib/cucumber/hooks.rb +1 -3
  91. data/lib/cucumber/load_path.rb +1 -0
  92. data/lib/cucumber/multiline_argument.rb +2 -2
  93. data/lib/cucumber/multiline_argument/data_table.rb +10 -10
  94. data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +4 -7
  95. data/lib/cucumber/multiline_argument/doc_string.rb +1 -0
  96. data/lib/cucumber/platform.rb +2 -1
  97. data/lib/cucumber/project_initializer.rb +1 -1
  98. data/lib/cucumber/rake/task.rb +7 -4
  99. data/lib/cucumber/rspec/disable_option_parser.rb +1 -0
  100. data/lib/cucumber/rspec/doubles.rb +1 -0
  101. data/lib/cucumber/running_test_case.rb +2 -1
  102. data/lib/cucumber/runtime.rb +5 -5
  103. data/lib/cucumber/runtime/after_hooks.rb +1 -0
  104. data/lib/cucumber/runtime/before_hooks.rb +1 -0
  105. data/lib/cucumber/runtime/for_programming_languages.rb +8 -7
  106. data/lib/cucumber/runtime/step_hooks.rb +2 -0
  107. data/lib/cucumber/runtime/support_code.rb +3 -7
  108. data/lib/cucumber/runtime/user_interface.rb +2 -3
  109. data/lib/cucumber/step_argument.rb +1 -0
  110. data/lib/cucumber/step_definition_light.rb +2 -1
  111. data/lib/cucumber/step_definitions.rb +1 -0
  112. data/lib/cucumber/step_match.rb +5 -7
  113. data/lib/cucumber/step_match_search.rb +1 -2
  114. data/lib/cucumber/term/ansicolor.rb +30 -30
  115. data/lib/cucumber/unit.rb +1 -0
  116. data/lib/cucumber/version +1 -1
  117. data/lib/simplecov_setup.rb +1 -0
  118. metadata +61 -117
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/filter'
3
4
  require 'cucumber/running_test_case'
4
5
  require 'cucumber/events'
@@ -6,7 +7,6 @@ require 'cucumber/events'
6
7
  module Cucumber
7
8
  module Filters
8
9
  class Retry < Core::Filter.new(:configuration)
9
-
10
10
  def test_case(test_case)
11
11
  configuration.on_event(:test_case_finished) do |event|
12
12
  next unless retry_required?(test_case, event)
@@ -25,7 +25,7 @@ module Cucumber
25
25
  end
26
26
 
27
27
  def test_case_counts
28
- @test_case_counts ||= Hash.new {|h,k| h[k] = 0 }
28
+ @test_case_counts ||= Hash.new {|h, k| h[k] = 0 }
29
29
  end
30
30
  end
31
31
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/filters/gated_receiver'
3
4
  require 'cucumber/filters/tag_limits/test_case_index'
4
5
  require 'cucumber/filters/tag_limits/verifier'
@@ -12,7 +13,7 @@ module Cucumber
12
13
  end
13
14
 
14
15
  class TagLimits
15
- def initialize(tag_limits, receiver=nil)
16
+ def initialize(tag_limits, receiver = nil)
16
17
  @tag_limits = tag_limits
17
18
  @gated_receiver = GatedReceiver.new(receiver)
18
19
  @test_case_index = TestCaseIndex.new
@@ -41,6 +42,5 @@ module Cucumber
41
42
  attr_reader :test_case_index
42
43
  attr_reader :verifier
43
44
  end
44
-
45
45
  end
46
46
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Filters
4
5
  class TagLimits
5
-
6
6
  class TestCaseIndex
7
7
  def initialize
8
8
  @index = Hash.new { |hash, key| hash[key] = [] }
@@ -26,7 +26,6 @@ module Cucumber
26
26
 
27
27
  attr_accessor :index
28
28
  end
29
-
30
29
  end
31
30
  end
32
31
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Filters
4
5
  class TagLimits
5
-
6
6
  class Verifier
7
7
  def initialize(tag_limits)
8
8
  @tag_limits = tag_limits
@@ -53,7 +53,6 @@ module Cucumber
53
53
  attr_reader :limit
54
54
  attr_reader :locations
55
55
  end
56
-
57
56
  end
58
57
  end
59
58
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/platform'
3
4
  require 'cucumber/term/ansicolor'
4
5
 
@@ -53,21 +54,21 @@ module Cucumber
53
54
  module ANSIColor
54
55
  include Cucumber::Term::ANSIColor
55
56
 
56
- ALIASES = Hash.new do |h,k|
57
+ ALIASES = Hash.new do |h, k|
57
58
  if k.to_s =~ /(.*)_param/
58
59
  h[$1] + ',bold'
59
60
  end
60
61
  end.merge({
61
- 'undefined' => 'yellow',
62
- 'pending' => 'yellow',
63
- 'flaky' => 'yellow',
64
- 'failed' => 'red',
65
- 'passed' => 'green',
66
- 'outline' => 'cyan',
67
- 'skipped' => 'cyan',
68
- 'comment' => 'grey',
69
- 'tag' => 'cyan'
70
- })
62
+ 'undefined' => 'yellow',
63
+ 'pending' => 'yellow',
64
+ 'flaky' => 'yellow',
65
+ 'failed' => 'red',
66
+ 'passed' => 'green',
67
+ 'outline' => 'cyan',
68
+ 'skipped' => 'cyan',
69
+ 'comment' => 'grey',
70
+ 'tag' => 'cyan'
71
+ })
71
72
 
72
73
  if ENV['CUCUMBER_COLORS'] # Example: export CUCUMBER_COLORS="passed=red:failed=yellow"
73
74
  ENV['CUCUMBER_COLORS'].split(':').each do |pair|
@@ -95,7 +96,7 @@ module Cucumber
95
96
  end
96
97
  # This resets the colour to the non-param colour
97
98
  def #{method_name}_param(string=nil, &proc)
98
- #{ALIASES[method_name+'_param'].split(",").join("(") + "(string, &proc" + ")" * ALIASES[method_name+'_param'].split(",").length} + #{ALIASES[method_name].split(",").join(' + ')}
99
+ #{ALIASES[method_name + '_param'].split(",").join("(") + "(string, &proc" + ")" * ALIASES[method_name + '_param'].split(",").length} + #{ALIASES[method_name].split(",").join(' + ')}
99
100
  end
100
101
  EOF
101
102
  eval(code)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'cucumber/platform'
3
2
 
3
+ require 'cucumber/platform'
4
4
 
5
5
  module Cucumber
6
6
  module Formatter
@@ -49,6 +49,5 @@ module Cucumber
49
49
  @exception
50
50
  end
51
51
  end
52
-
53
52
  end
54
53
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/formatter/ansicolor'
3
4
  require 'cucumber/formatter/duration'
4
5
  require 'cucumber/gherkin/i18n'
5
6
 
6
7
  module Cucumber
7
8
  module Formatter
8
-
9
9
  # This module contains helper methods that are used by formatters that
10
10
  # print output to the terminal.
11
11
  #
@@ -111,7 +111,7 @@ module Cucumber
111
111
  # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/10655
112
112
  def linebreaks(s, max)
113
113
  return s unless max && max > 0
114
- s.gsub(/.{1,#{max}}(?:\s|\Z)/){($& + 5.chr).gsub(/\n\005/,"\n").gsub(/\005/,"\n")}.rstrip
114
+ s.gsub(/.{1,#{max}}(?:\s|\Z)/) {($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n")}.rstrip
115
115
  end
116
116
 
117
117
  def collect_snippet_data(test_step, result)
@@ -127,9 +127,9 @@ module Cucumber
127
127
  return unless options[:snippets]
128
128
  return if runtime.steps(:undefined).empty?
129
129
 
130
- snippet_text_proc = lambda { |step_keyword, step_name, multiline_arg|
130
+ snippet_text_proc = lambda do |step_keyword, step_name, multiline_arg|
131
131
  runtime.snippet_text(step_keyword, step_name, multiline_arg)
132
- }
132
+ end
133
133
  do_print_snippets(snippet_text_proc)
134
134
  end
135
135
 
@@ -165,8 +165,8 @@ module Cucumber
165
165
  # no-op
166
166
  end
167
167
 
168
- #define @delayed_messages = [] in your Formatter if you want to
169
- #activate this feature
168
+ # define @delayed_messages = [] in your Formatter if you want to
169
+ # activate this feature
170
170
  def puts(*messages)
171
171
  if @delayed_messages
172
172
  @delayed_messages += messages
@@ -211,12 +211,12 @@ module Cucumber
211
211
  profiles_sentence = profiles.size == 1 ? profiles.first :
212
212
  "#{profiles[0...-1].join(', ')} and #{profiles.last}"
213
213
 
214
- @io.puts "Using the #{profiles_sentence} profile#{'s' if profiles.size> 1}..."
214
+ @io.puts "Using the #{profiles_sentence} profile#{'s' if profiles.size > 1}..."
215
215
  end
216
216
 
217
217
  private
218
218
 
219
- FORMATS = Hash.new{ |hash, format| hash[format] = method(format).to_proc }
219
+ FORMATS = Hash.new { |hash, format| hash[format] = method(format).to_proc }
220
220
 
221
221
  def format_for(*keys)
222
222
  key = keys.join('_').to_sym
@@ -241,9 +241,9 @@ module Cucumber
241
241
 
242
242
  def snippet_text(step_keyword, step_name, multiline_arg)
243
243
  keyword = Cucumber::Gherkin::I18n.code_keyword_for(step_keyword).strip
244
- config.snippet_generators.map { |generator|
244
+ config.snippet_generators.map do |generator|
245
245
  generator.call(keyword, step_name, multiline_arg, config.snippet_type)
246
- }.join("\n")
246
+ end.join("\n")
247
247
  end
248
248
 
249
249
  class SnippetData
@@ -252,7 +252,6 @@ module Cucumber
252
252
  @actual_keyword, @step = actual_keyword, step
253
253
  end
254
254
  end
255
-
256
255
  end
257
256
  end
258
257
  end
@@ -29,14 +29,14 @@ module Cucumber
29
29
  end
30
30
 
31
31
  def status_counts(summary)
32
- counts = Core::Test::Result::TYPES.map { |status|
32
+ counts = Core::Test::Result::TYPES.map do |status|
33
33
  count = summary.total(status)
34
34
  [status, count]
35
- }.select { |status, count|
35
+ end.select do |status, count|
36
36
  count > 0
37
- }.map { |status, count|
37
+ end.map do |status, count|
38
38
  format_string("#{count} #{status}", status)
39
- }
39
+ end
40
40
  "(#{counts.join(", ")})" if counts.any?
41
41
  end
42
42
  end
@@ -14,7 +14,7 @@ module Cucumber
14
14
  @previous_test_case = event.test_case
15
15
  @issues[event.result.to_sym] << event.test_case unless event.result.ok?(@config.strict)
16
16
  elsif event.result.passed?
17
- @issues[:flaky] << event.test_case unless Core::Test::Result::Flaky.ok?(@config.strict)
17
+ @issues[:flaky] << event.test_case unless Core::Test::Result::Flaky.ok?(@config.strict.strict?(:flaky))
18
18
  @issues[:failed].delete(event.test_case)
19
19
  end
20
20
  end
@@ -34,10 +34,10 @@ module Cucumber
34
34
 
35
35
  def scenario_listing(type, test_cases)
36
36
  return [] if test_cases.empty?
37
- [ format_string("#{type_heading(type)} Scenarios:", type) ] + test_cases.map { |test_case|
37
+ [format_string("#{type_heading(type)} Scenarios:", type)] + test_cases.map do |test_case|
38
38
  source = @config.source? ? format_string(" # #{test_case.keyword}: #{test_case.name}", :comment) : ''
39
39
  format_string("cucumber #{profiles_string}" + test_case.location, type) + source
40
- }
40
+ end
41
41
  end
42
42
 
43
43
  def type_heading(type)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Formatter
4
5
  module Duration
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Formatter
4
-
5
5
  class DurationExtractor
6
6
  attr_reader :result_duration
7
7
  def initialize(result)
@@ -1,20 +1,23 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/formatter/io'
3
4
  require 'cucumber/formatter/console'
4
5
 
5
6
  module Cucumber
6
7
  module Formatter
7
-
8
8
  class FailFast
9
-
10
9
  def initialize(configuration)
10
+ @previous_test_case = nil
11
11
  configuration.on_event :test_case_finished do |event|
12
- _test_case, result = *event.attributes
13
- Cucumber.wants_to_quit = true unless result.ok?(configuration.strict)
12
+ test_case, result = *event.attributes
13
+ if test_case != @previous_test_case
14
+ @previous_test_case = event.test_case
15
+ Cucumber.wants_to_quit = true unless result.ok?(configuration.strict)
16
+ elsif result.passed?
17
+ Cucumber.wants_to_quit = false
18
+ end
14
19
  end
15
20
  end
16
-
17
21
  end
18
-
19
22
  end
20
23
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Formatter
4
-
5
5
  # Forwards any messages sent to this object to all recipients
6
6
  # that respond to that message.
7
7
  class Fanout < BasicObject
@@ -21,8 +21,6 @@ module Cucumber
21
21
  def respond_to_missing?(name, include_private = false)
22
22
  recipients.any? { |recipient| recipient.respond_to?(name, include_private) }
23
23
  end
24
-
25
24
  end
26
-
27
25
  end
28
26
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Formatter
4
5
  class HookQueryVisitor
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erb'
3
4
  require 'cucumber/formatter/duration'
4
5
  require 'cucumber/formatter/io'
@@ -8,8 +9,7 @@ require 'pathname'
8
9
  module Cucumber
9
10
  module Formatter
10
11
  class Html
11
-
12
- # TODO: remove coupling to types
12
+ # TODO: remove coupling to types
13
13
  AST_CLASSES = {
14
14
  Cucumber::Core::Ast::Scenario => 'scenario',
15
15
  Cucumber::Core::Ast::ScenarioOutline => 'scenario outline'
@@ -42,13 +42,13 @@ module Cucumber
42
42
  def embed(src, mime_type, label)
43
43
  if image?(mime_type)
44
44
  src = src_is_file_or_data?(src) ? src : "data:#{standardize_mime_type(mime_type)},#{src}"
45
- builder.embed(type: :image, src: set_path(src), label: label, id: next_id(:img))
45
+ builder.embed(type: :image, src: path(src), label: label, id: next_id(:img))
46
46
  else
47
47
  builder.embed(type: :text, src: src, label: label, id: next_id(:text))
48
48
  end
49
49
  end
50
50
 
51
- def set_path(src)
51
+ def path(src)
52
52
  if @io.respond_to?(:path) && File.file?(src)
53
53
  out_dir = Pathname.new(File.dirname(File.absolute_path(@io.path)))
54
54
  src = Pathname.new(File.absolute_path(src)).relative_path_from(out_dir)
@@ -70,7 +70,7 @@ module Cucumber
70
70
  end
71
71
 
72
72
  def before_features(features)
73
- @step_count = features && features.step_count || 0 #TODO: Make this work with core!
73
+ @step_count = features && features.step_count || 0 # TODO: Make this work with core!
74
74
 
75
75
  builder.build_document!
76
76
  builder.format_features! features
@@ -153,7 +153,7 @@ module Cucumber
153
153
  end
154
154
 
155
155
  def before_feature_element(feature_element)
156
- @scenario_number+=1
156
+ @scenario_number += 1
157
157
  @scenario_red = false
158
158
  css_class = AST_CLASSES[feature_element.class]
159
159
  builder << "<div class='#{css_class}'>"
@@ -251,7 +251,7 @@ module Cucumber
251
251
  end
252
252
  @status = status
253
253
  return if @hide_this_step
254
- set_scenario_color(status)
254
+ scenario_color(status)
255
255
  builder << "<li id='#{@step_id}' class='step #{status}'>"
256
256
  end
257
257
 
@@ -266,7 +266,7 @@ module Cucumber
266
266
  builder.pre do |pre|
267
267
  # TODO: snippet text should be an event sent to the formatter so we don't
268
268
  # have this couping to the runtime.
269
- pre << @runtime.snippet_text(keyword,step_match.instance_variable_get('@name') || '', @step.multiline_arg)
269
+ pre << @runtime.snippet_text(keyword, step_match.instance_variable_get('@name') || '', @step.multiline_arg)
270
270
  end
271
271
  end
272
272
  builder << '</li>'
@@ -353,25 +353,22 @@ module Cucumber
353
353
  attributes = {:id => "#{@row_id}_#{@col_index}", :class => 'step'}
354
354
  attributes[:class] += " #{status}" if status
355
355
  build_cell(@cell_type, value, attributes)
356
- set_scenario_color(status) if @inside_outline
356
+ scenario_color(status) if @inside_outline
357
357
  @col_index += 1
358
358
  end
359
359
 
360
360
  def puts(message)
361
361
  @delayed_messages << message
362
- #builder.pre(message, :class => 'message')
363
362
  end
364
363
 
365
364
  def print_messages
366
365
  return if @delayed_messages.empty?
367
366
 
368
- #builder.ol do
369
- @delayed_messages.each do |ann|
370
- builder.li(:class => 'step message') do
371
- builder << ann
372
- end
367
+ @delayed_messages.each do |ann|
368
+ builder.li(:class => 'step message') do
369
+ builder << ann
373
370
  end
374
- #end
371
+ end
375
372
  empty_messages
376
373
  end
377
374
 
@@ -436,7 +433,7 @@ module Cucumber
436
433
  builder << extra unless extra == ''
437
434
  end
438
435
 
439
- def set_scenario_color(status)
436
+ def scenario_color(status)
440
437
  if status.nil? || status == :undefined || status == :pending
441
438
  set_scenario_color_pending
442
439
  end
@@ -467,7 +464,7 @@ module Cucumber
467
464
  end
468
465
 
469
466
  def build_step(keyword, step_match, _status)
470
- step_name = step_match.format_args(lambda{|param| %{<span class="param">#{param}</span>}})
467
+ step_name = step_match.format_args(lambda {|param| %{<span class="param">#{param}</span>}})
471
468
  builder.div(:class => 'step_name') do |div|
472
469
  builder.span(keyword, :class => 'keyword')
473
470
  builder.span(:class => 'step val') do |name|
@@ -492,7 +489,7 @@ module Cucumber
492
489
  def build_cell(cell_type, value, attributes)
493
490
  builder.__send__(cell_type, attributes) do
494
491
  builder.div do
495
- builder.span(value,:class => 'step param')
492
+ builder.span(value, :class => 'step param')
496
493
  end
497
494
  end
498
495
  end
@@ -531,11 +528,11 @@ module Cucumber
531
528
  def print_stat_string(_features)
532
529
  string = String.new
533
530
  string << dump_count(@runtime.scenarios.length, 'scenario')
534
- scenario_count = print_status_counts{|status| @runtime.scenarios(status)}
531
+ scenario_count = print_status_counts {|status| @runtime.scenarios(status)}
535
532
  string << scenario_count if scenario_count
536
533
  string << '<br />'
537
534
  string << dump_count(@runtime.steps.length, 'step')
538
- step_count = print_status_counts{|status| @runtime.steps(status)}
535
+ step_count = print_status_counts {|status| @runtime.steps(status)}
539
536
  string << step_count if step_count
540
537
  end
541
538
 
@@ -547,7 +544,7 @@ module Cucumber
547
544
  return " (#{counts.join(', ')})" if counts.any?
548
545
  end
549
546
 
550
- def dump_count(count, what, state=nil)
547
+ def dump_count(count, what, state = nil)
551
548
  [count, state, "#{what}#{count == 1 ? '' : 's'}"].compact.join(' ')
552
549
  end
553
550
 
@@ -568,7 +565,7 @@ module Cucumber
568
565
  def snippet(error)
569
566
  raw_code, line = snippet_for(error[0])
570
567
  highlighted = @@converter.convert(raw_code, false)
571
- highlighted << "\n<span class=\"comment\"># gem install syntax to get syntax highlighting</span>" if @@converter.is_a?(NullConverter)
568
+ highlighted += "\n<span class=\"comment\"># gem install syntax to get syntax highlighting</span>" if @@converter.is_a?(NullConverter)
572
569
  post_process(highlighted, line)
573
570
  end
574
571
 
@@ -585,12 +582,12 @@ module Cucumber
585
582
  def lines_around(file, line)
586
583
  if File.file?(file)
587
584
  begin
588
- lines = File.open(file).read.split("\n")
589
- rescue ArgumentError
590
- return "# Couldn't get snippet for #{file}"
591
- end
592
- min = [0, line-3].max
593
- max = [line+1, lines.length-1].min
585
+ lines = File.open(file).read.split("\n")
586
+ rescue ArgumentError
587
+ return "# Couldn't get snippet for #{file}"
588
+ end
589
+ min = [0, line - 3].max
590
+ max = [line + 1, lines.length - 1].min
594
591
  selected_lines = []
595
592
  selected_lines.join("\n")
596
593
  lines[min..max].join("\n")
@@ -602,13 +599,12 @@ module Cucumber
602
599
  def post_process(highlighted, offending_line)
603
600
  new_lines = []
604
601
  highlighted.split("\n").each_with_index do |line, i|
605
- new_line = "<span class=\"linenum\">#{offending_line+i-2}</span>#{line}"
602
+ new_line = "<span class=\"linenum\">#{offending_line + i - 2}</span>#{line}"
606
603
  new_line = "<span class=\"offending\">#{new_line}</span>" if i == 2
607
604
  new_lines << new_line
608
605
  end
609
606
  new_lines.join("\n")
610
607
  end
611
-
612
608
  end
613
609
  end
614
610
  end