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
@@ -38,7 +38,7 @@ module Cucumber
38
38
  matched_cols = []
39
39
 
40
40
  header_values.each_with_index do |v, i|
41
- mapped_index = unmatched_cols.index{|unmapped_col| unmapped_col.first == v}
41
+ mapped_index = unmatched_cols.index {|unmapped_col| unmapped_col.first == v}
42
42
  if mapped_index
43
43
  matched_cols << unmatched_cols.delete_at(mapped_index)
44
44
  else
@@ -68,7 +68,6 @@ module Cucumber
68
68
  array[0].is_a?(Array) ? array : [array]
69
69
  end
70
70
 
71
-
72
71
  def perform_diff
73
72
  inserted = 0
74
73
  missing = 0
@@ -77,13 +76,13 @@ module Cucumber
77
76
  changes.each do |change|
78
77
  if change.action == '-'
79
78
  @missing_row_pos = change.position + inserted
80
- cell_matrix[missing_row_pos].each{|cell| cell.status = :undefined}
79
+ cell_matrix[missing_row_pos].each {|cell| cell.status = :undefined}
81
80
  row_indices.insert(missing_row_pos, nil)
82
81
  missing += 1
83
82
  else # '+'
84
83
  @insert_row_pos = change.position + missing
85
84
  inserted_row = change.element
86
- inserted_row.each{|cell| cell.status = :comment}
85
+ inserted_row.each {|cell| cell.status = :comment}
87
86
  cell_matrix.insert(insert_row_pos, inserted_row)
88
87
  row_indices[insert_row_pos] = nil
89
88
  inspect_rows(cell_matrix[missing_row_pos], inserted_row) if last_change == '-'
@@ -109,7 +108,6 @@ module Cucumber
109
108
  end
110
109
  end
111
110
 
112
-
113
111
  def fill_in_missing_values
114
112
  other_table_cell_matrix.each_with_index do |other_row, i|
115
113
  row_index = row_indices.index(i)
@@ -123,7 +121,7 @@ module Cucumber
123
121
  end
124
122
 
125
123
  def missing_col
126
- cell_matrix[0].find{|cell| cell.status == :undefined}
124
+ cell_matrix[0].find {|cell| cell.status == :undefined}
127
125
  end
128
126
 
129
127
  def surplus_col
@@ -134,7 +132,6 @@ module Cucumber
134
132
  cell_matrix[0] != original_header
135
133
  end
136
134
 
137
-
138
135
  def raise_error
139
136
  table = DataTable.from([[]])
140
137
  table.instance_variable_set :@cell_matrix, cell_matrix
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module MultilineArgument
4
5
  class DocString < SimpleDelegator
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Detect the platform we're running on so we can tweak behaviour
3
4
  # in various places.
4
5
  require 'rbconfig'
@@ -17,7 +18,7 @@ module Cucumber
17
18
  attr_accessor :use_full_backtrace
18
19
 
19
20
  # @private
20
- def file_mode(m, encoding='UTF-8')
21
+ def file_mode(m, encoding = 'UTF-8')
21
22
  "#{m}:#{encoding}"
22
23
  end
23
24
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
- module Cucumber
3
2
 
3
+ module Cucumber
4
4
  # Generates generic file structure for a cucumber project
5
5
  class ProjectInitializer
6
6
  def run
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/platform'
3
4
  require 'cucumber/gherkin/formatter/ansi_escapes'
4
5
  begin
5
6
  # Support Rake > 0.8.7
6
7
  require 'rake/dsl_definition'
8
+ # rubocop:disable Lint/HandleExceptions
7
9
  rescue LoadError
10
+ # rubocop:enable Lint/HandleExceptions
8
11
  end
9
12
 
10
13
  module Cucumber
@@ -36,7 +39,7 @@ module Cucumber
36
39
 
37
40
  def initialize(libs, cucumber_opts, feature_files)
38
41
  raise 'libs must be an Array when running in-process' unless Array === libs
39
- libs.reverse.each{|lib| $LOAD_PATH.unshift(lib)}
42
+ libs.reverse.each {|lib| $LOAD_PATH.unshift(lib)}
40
43
  @args = (
41
44
  cucumber_opts +
42
45
  feature_files
@@ -82,7 +85,7 @@ module Cucumber
82
85
  def cmd
83
86
  if use_bundler
84
87
  [
85
- Cucumber::RUBY_BINARY,'-S', 'bundle', 'exec', 'cucumber',
88
+ Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'cucumber',
86
89
  @cucumber_opts, @feature_files
87
90
  ].flatten
88
91
  else
@@ -151,7 +154,7 @@ module Cucumber
151
154
 
152
155
  def runner(_task_args = nil) #:nodoc:
153
156
  cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile]
154
- if(@fork)
157
+ if @fork
155
158
  return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files)
156
159
  end
157
160
  InProcessCucumberRunner.new(libs, cucumber_opts, feature_files)
@@ -166,7 +169,7 @@ module Cucumber
166
169
  end
167
170
 
168
171
  def make_command_line_safe(list)
169
- list.map{|string| string.gsub(' ', '\ ')}
172
+ list.map {|string| string.gsub(' ', '\ ')}
170
173
  end
171
174
  end
172
175
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'optparse'
3
4
 
4
5
  module Spec #:nodoc:
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rspec/mocks'
3
4
 
4
5
  World(RSpec::Mocks::ExampleMethods)
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'delegate'
3
4
 
4
5
  module Cucumber
5
- # Represents the current status of a running test case.
6
+ # Represents the current status of a running test case.
6
7
  #
7
8
  # This wraps a `Cucumber::Core::Test::Case` and delegates
8
9
  # many methods to that object.
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # frozen_string_literal: true
3
+
3
4
  require 'fileutils'
4
5
  require 'multi_json'
5
6
  require 'cucumber/configuration'
@@ -105,7 +106,7 @@ module Cucumber
105
106
 
106
107
  # Returns Ast::DocString for +string_without_triple_quotes+.
107
108
  #
108
- def doc_string(string_without_triple_quotes, content_type='', _line_offset=0)
109
+ def doc_string(string_without_triple_quotes, content_type = '', _line_offset = 0)
109
110
  location = Core::Ast::Location.of_caller
110
111
  Core::Ast::DocString.new(string_without_triple_quotes, content_type, location)
111
112
  end
@@ -214,7 +215,8 @@ module Cucumber
214
215
  formatter = factory.new(runtime_facade, path_or_io, cli_options)
215
216
  Formatter::LegacyApi::Adapter.new(
216
217
  Formatter::IgnoreMissingMessages.new(formatter),
217
- results, @configuration)
218
+ results, @configuration
219
+ )
218
220
  end
219
221
 
220
222
  def accept_options?(factory)
@@ -245,7 +247,7 @@ module Cucumber
245
247
  filters << Cucumber::Core::Test::NameFilter.new(name_regexps)
246
248
  filters << Cucumber::Core::Test::LocationsFilter.new(filespecs.locations)
247
249
  filters << Filters::Randomizer.new(@configuration.seed) if @configuration.randomize?
248
- # TODO: can we just use Glue::RegistryAndMore's step definitions directly?
250
+ # TODO: can we just use Glue::RegistryAndMore's step definitions directly?
249
251
  step_match_search = StepMatchSearch.new(@support_code.registry.method(:step_matches), @configuration)
250
252
  filters << Filters::ActivateSteps.new(step_match_search, @configuration)
251
253
  @configuration.filters.each do |filter|
@@ -277,7 +279,5 @@ module Cucumber
277
279
  def log
278
280
  Cucumber.logger
279
281
  end
280
-
281
282
  end
282
-
283
283
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  class Runtime
4
5
  class AfterHooks
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/hooks'
3
4
 
4
5
  module Cucumber
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'forwardable'
3
4
  require 'cucumber/core/ast/doc_string'
4
5
 
@@ -18,15 +19,15 @@ module Cucumber
18
19
  end
19
20
 
20
21
  def_delegators :@user_interface,
21
- :embed,
22
- :ask,
23
- :puts,
24
- :features_paths,
25
- :step_match
22
+ :embed,
23
+ :ask,
24
+ :puts,
25
+ :features_paths,
26
+ :step_match
26
27
 
27
28
  def_delegators :@support_code,
28
- :invoke_dynamic_steps,
29
- :invoke_dynamic_step
29
+ :invoke_dynamic_steps,
30
+ :invoke_dynamic_step
30
31
  end
31
32
  end
32
33
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  class Runtime
4
5
  class StepHooks
@@ -13,6 +14,7 @@ module Cucumber
13
14
  end
14
15
 
15
16
  private
17
+
16
18
  def after_step_hooks(test_step)
17
19
  @hooks.map do |hook|
18
20
  action = ->(*args) { hook.invoke('AfterStep', [args, test_step]) }
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/constantize'
3
4
  require 'cucumber/runtime/for_programming_languages'
4
5
  require 'cucumber/runtime/step_hooks'
@@ -8,14 +9,10 @@ require 'cucumber/gherkin/steps_parser'
8
9
  require 'cucumber/step_match_search'
9
10
 
10
11
  module Cucumber
11
-
12
12
  class Runtime
13
-
14
13
  class SupportCode
15
-
16
14
  require 'forwardable'
17
15
  class StepInvoker
18
-
19
16
  def initialize(support_code)
20
17
  @support_code = support_code
21
18
  end
@@ -48,7 +45,7 @@ module Cucumber
48
45
 
49
46
  attr_reader :registry
50
47
 
51
- def initialize(user_interface, configuration=Configuration.default)
48
+ def initialize(user_interface, configuration = Configuration.default)
52
49
  @configuration = configuration
53
50
  # TODO: needs a better name, or inlining its methods
54
51
  @runtime_facade = Runtime::ForProgrammingLanguages.new(self, user_interface)
@@ -76,7 +73,7 @@ module Cucumber
76
73
  # steps which are compiled into test steps before execution.
77
74
  #
78
75
  # These are commonly called nested steps.
79
- def invoke_dynamic_step(step_name, multiline_argument, _location=nil)
76
+ def invoke_dynamic_step(step_name, multiline_argument, _location = nil)
80
77
  matches = step_matches(step_name)
81
78
  raise UndefinedDynamicStep, step_name if matches.empty?
82
79
  matches.first.invoke(multiline_argument)
@@ -150,7 +147,6 @@ module Cucumber
150
147
  def log
151
148
  Cucumber.logger
152
149
  end
153
-
154
150
  end
155
151
  end
156
152
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'timeout'
3
4
 
4
5
  module Cucumber
5
6
  class Runtime
6
-
7
7
  module UserInterface
8
8
  attr_writer :visitor
9
9
 
@@ -33,7 +33,7 @@ module Cucumber
33
33
  STDOUT.flush
34
34
  puts(question)
35
35
 
36
- answer = if(Cucumber::JRUBY)
36
+ answer = if Cucumber::JRUBY
37
37
  jruby_gets(timeout_seconds)
38
38
  else
39
39
  mri_gets(timeout_seconds)
@@ -74,6 +74,5 @@ module Cucumber
74
74
  answer
75
75
  end
76
76
  end
77
-
78
77
  end
79
78
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  # Defines the location and value of a captured argument from the step
4
5
  # text
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  # TODO: pointless, ancient, kill with fire.
4
5
  # Only used for keeping track of available and invoked step definitions
@@ -16,7 +17,7 @@ module Cucumber
16
17
  end
17
18
 
18
19
  def hash
19
- regexp_source.hash + 31*location.to_s.hash
20
+ regexp_source.hash + 31 * location.to_s.hash
20
21
  end
21
22
  end
22
23
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  class StepDefinitions
4
5
  def initialize(configuration = Configuration.default)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/multiline_argument'
3
4
 
4
5
  module Cucumber
5
-
6
6
  # Represents the match found between a Test Step and its activation
7
7
  class StepMatch #:nodoc:
8
8
  attr_reader :step_definition, :step_arguments
@@ -46,7 +46,7 @@ module Cucumber
46
46
  #
47
47
  # lambda { |param| "[#{param}]" }
48
48
  #
49
- def format_args(format = lambda{|a| a}, &proc)
49
+ def format_args(format = lambda {|a| a}, &proc)
50
50
  replace_arguments(@name_to_match, @step_arguments, format, &proc)
51
51
  end
52
52
 
@@ -66,7 +66,7 @@ module Cucumber
66
66
  @step_definition.expression.source.to_s.unpack('U*').length
67
67
  end
68
68
 
69
- def replace_arguments(string, step_arguments, format, &proc)
69
+ def replace_arguments(string, step_arguments, format)
70
70
  s = string.dup
71
71
  offset = past_offset = 0
72
72
  step_arguments.each do |step_argument|
@@ -74,7 +74,7 @@ module Cucumber
74
74
  next if group.value.nil? || group.start < past_offset
75
75
 
76
76
  replacement = if block_given?
77
- proc.call(group.value)
77
+ yield(group.value)
78
78
  elsif Proc === format
79
79
  format.call(group.value)
80
80
  else
@@ -93,6 +93,7 @@ module Cucumber
93
93
  end
94
94
 
95
95
  private
96
+
96
97
  def deep_clone_args
97
98
  Marshal.load( Marshal.dump( args ) )
98
99
  end
@@ -145,7 +146,6 @@ module Cucumber
145
146
  end
146
147
 
147
148
  class AmbiguousStepMatch
148
-
149
149
  def initialize(error)
150
150
  @error = error
151
151
  end
@@ -153,7 +153,5 @@ module Cucumber
153
153
  def activate(test_step)
154
154
  return test_step.with_action { raise @error }
155
155
  end
156
-
157
156
  end
158
-
159
157
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module StepMatchSearch
4
5
  def self.new(search, configuration)
@@ -48,7 +49,6 @@ module Cucumber
48
49
  top_groups
49
50
  end
50
51
  end
51
-
52
52
  end
53
53
 
54
54
  require 'delegate'
@@ -62,6 +62,5 @@ module Cucumber
62
62
  @match_cache[step_name] = super(step_name)
63
63
  end
64
64
  end
65
-
66
65
  end
67
66
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Term
4
5
  # The ANSIColor module can be used for namespacing and mixed into your own
@@ -6,34 +7,34 @@ module Cucumber
6
7
  module ANSIColor
7
8
  # :stopdoc:
8
9
  ATTRIBUTES = [
9
- [ :clear , 0 ],
10
- [ :reset , 0 ], # synonym for :clear
11
- [ :bold , 1 ],
12
- [ :dark , 2 ],
13
- [ :italic , 3 ], # not widely implemented
14
- [ :underline , 4 ],
15
- [ :underscore , 4 ], # synonym for :underline
16
- [ :blink , 5 ],
17
- [ :rapid_blink , 6 ], # not widely implemented
18
- [ :negative , 7 ], # no reverse because of String#reverse
19
- [ :concealed , 8 ],
20
- [ :strikethrough, 9 ], # not widely implemented
21
- [ :black , 30 ],
22
- [ :red , 31 ],
23
- [ :green , 32 ],
24
- [ :yellow , 33 ],
25
- [ :blue , 34 ],
26
- [ :magenta , 35 ],
27
- [ :cyan , 36 ],
28
- [ :white , 37 ],
29
- [ :on_black , 40 ],
30
- [ :on_red , 41 ],
31
- [ :on_green , 42 ],
32
- [ :on_yellow , 43 ],
33
- [ :on_blue , 44 ],
34
- [ :on_magenta , 45 ],
35
- [ :on_cyan , 46 ],
36
- [ :on_white , 47 ]
10
+ [:clear, 0],
11
+ [:reset, 0], # synonym for :clear
12
+ [:bold, 1],
13
+ [:dark, 2],
14
+ [:italic, 3], # not widely implemented
15
+ [:underline, 4],
16
+ [:underscore, 4], # synonym for :underline
17
+ [:blink, 5],
18
+ [:rapid_blink, 6], # not widely implemented
19
+ [:negative, 7], # no reverse because of String#reverse
20
+ [:concealed, 8],
21
+ [:strikethrough, 9], # not widely implemented
22
+ [:black, 30],
23
+ [:red, 31],
24
+ [:green, 32],
25
+ [:yellow, 33],
26
+ [:blue, 34],
27
+ [:magenta, 35],
28
+ [:cyan, 36],
29
+ [:white, 37],
30
+ [:on_black, 40],
31
+ [:on_red, 41],
32
+ [:on_green, 42],
33
+ [:on_yellow, 43],
34
+ [:on_blue, 44],
35
+ [:on_magenta, 45],
36
+ [:on_cyan, 46],
37
+ [:on_white, 47]
37
38
  ]
38
39
 
39
40
  ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
@@ -56,7 +57,7 @@ module Cucumber
56
57
  ATTRIBUTES.each do |c, v|
57
58
  eval %Q{
58
59
  def #{c}(string = nil)
59
- result = ''
60
+ result = String.new
60
61
  result << "\e[#{v}m" if Cucumber::Term::ANSIColor.coloring?
61
62
  if block_given?
62
63
  result << yield
@@ -77,7 +78,6 @@ module Cucumber
77
78
  # uncoloring strings.
78
79
  COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
79
80
 
80
-
81
81
  def self.included(klass)
82
82
  if klass == String
83
83
  ATTRIBUTES.delete(:clear)