rspec-core 3.0.4 → 3.1.0

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 (55) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +67 -0
  5. data/lib/rspec/core.rb +3 -1
  6. data/lib/rspec/core/backtrace_formatter.rb +13 -10
  7. data/lib/rspec/core/configuration.rb +123 -57
  8. data/lib/rspec/core/configuration_options.rb +12 -12
  9. data/lib/rspec/core/drb.rb +11 -11
  10. data/lib/rspec/core/dsl.rb +0 -1
  11. data/lib/rspec/core/example.rb +39 -12
  12. data/lib/rspec/core/example_group.rb +31 -98
  13. data/lib/rspec/core/filter_manager.rb +16 -17
  14. data/lib/rspec/core/formatters.rb +14 -13
  15. data/lib/rspec/core/formatters/base_formatter.rb +8 -113
  16. data/lib/rspec/core/formatters/base_text_formatter.rb +3 -5
  17. data/lib/rspec/core/formatters/console_codes.rb +1 -2
  18. data/lib/rspec/core/formatters/deprecation_formatter.rb +2 -3
  19. data/lib/rspec/core/formatters/documentation_formatter.rb +3 -4
  20. data/lib/rspec/core/formatters/helpers.rb +5 -6
  21. data/lib/rspec/core/formatters/html_formatter.rb +20 -19
  22. data/lib/rspec/core/formatters/html_printer.rb +6 -5
  23. data/lib/rspec/core/formatters/json_formatter.rb +3 -2
  24. data/lib/rspec/core/formatters/profile_formatter.rb +0 -2
  25. data/lib/rspec/core/formatters/progress_formatter.rb +4 -4
  26. data/lib/rspec/core/formatters/protocol.rb +163 -0
  27. data/lib/rspec/core/formatters/snippet_extractor.rb +7 -6
  28. data/lib/rspec/core/hooks.rb +25 -10
  29. data/lib/rspec/core/memoized_helpers.rb +7 -5
  30. data/lib/rspec/core/metadata.rb +29 -30
  31. data/lib/rspec/core/metadata_filter.rb +66 -66
  32. data/lib/rspec/core/minitest_assertions_adapter.rb +1 -1
  33. data/lib/rspec/core/mocking_adapters/flexmock.rb +3 -1
  34. data/lib/rspec/core/mocking_adapters/mocha.rb +3 -1
  35. data/lib/rspec/core/mocking_adapters/null.rb +2 -0
  36. data/lib/rspec/core/mocking_adapters/rr.rb +3 -1
  37. data/lib/rspec/core/mocking_adapters/rspec.rb +3 -1
  38. data/lib/rspec/core/notifications.rb +36 -29
  39. data/lib/rspec/core/option_parser.rb +29 -25
  40. data/lib/rspec/core/ordering.rb +8 -9
  41. data/lib/rspec/core/pending.rb +6 -8
  42. data/lib/rspec/core/project_initializer.rb +4 -2
  43. data/lib/rspec/core/project_initializer/.rspec +0 -1
  44. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +37 -26
  45. data/lib/rspec/core/rake_task.rb +37 -19
  46. data/lib/rspec/core/reporter.rb +13 -16
  47. data/lib/rspec/core/ruby_project.rb +2 -2
  48. data/lib/rspec/core/runner.rb +11 -14
  49. data/lib/rspec/core/shared_example_group.rb +14 -13
  50. data/lib/rspec/core/test_unit_assertions_adapter.rb +1 -1
  51. data/lib/rspec/core/version.rb +1 -1
  52. data/lib/rspec/core/warnings.rb +4 -4
  53. data/lib/rspec/core/world.rb +22 -24
  54. metadata +6 -5
  55. metadata.gz.sig +0 -0
@@ -6,89 +6,89 @@ module RSpec
6
6
  # having metadata be a raw hash (not a custom subclass), so externalizing
7
7
  # this filtering logic helps us move in that direction.
8
8
  module MetadataFilter
9
- extend self
10
-
11
- # @private
12
- def any_apply?(filters, metadata)
13
- filters.any? { |k, v| filter_applies?(k, v, metadata) }
14
- end
9
+ class << self
10
+ # @private
11
+ def any_apply?(filters, metadata)
12
+ filters.any? { |k, v| filter_applies?(k, v, metadata) }
13
+ end
15
14
 
16
- # @private
17
- def all_apply?(filters, metadata)
18
- filters.all? { |k, v| filter_applies?(k, v, metadata) }
19
- end
15
+ # @private
16
+ def all_apply?(filters, metadata)
17
+ filters.all? { |k, v| filter_applies?(k, v, metadata) }
18
+ end
20
19
 
21
- # @private
22
- def filter_applies?(key, value, metadata)
23
- silence_metadata_example_group_deprecations do
24
- return filter_applies_to_any_value?(key, value, metadata) if Array === metadata[key] && !(Proc === value)
25
- return location_filter_applies?(value, metadata) if key == :locations
26
- return filters_apply?(key, value, metadata) if Hash === value
20
+ # @private
21
+ def filter_applies?(key, value, metadata)
22
+ silence_metadata_example_group_deprecations do
23
+ return filter_applies_to_any_value?(key, value, metadata) if Array === metadata[key] && !(Proc === value)
24
+ return location_filter_applies?(value, metadata) if key == :locations
25
+ return filters_apply?(key, value, metadata) if Hash === value
27
26
 
28
- return false unless metadata.has_key?(key)
27
+ return false unless metadata.key?(key)
29
28
 
30
- case value
31
- when Regexp
32
- metadata[key] =~ value
33
- when Proc
34
- case value.arity
35
- when 0 then value.call
36
- when 2 then value.call(metadata[key], metadata)
37
- else value.call(metadata[key])
29
+ case value
30
+ when Regexp
31
+ metadata[key] =~ value
32
+ when Proc
33
+ case value.arity
34
+ when 0 then value.call
35
+ when 2 then value.call(metadata[key], metadata)
36
+ else value.call(metadata[key])
37
+ end
38
+ else
39
+ metadata[key].to_s == value.to_s
38
40
  end
39
- else
40
- metadata[key].to_s == value.to_s
41
41
  end
42
42
  end
43
- end
44
43
 
45
- private
44
+ private
46
45
 
47
- def filter_applies_to_any_value?(key, value, metadata)
48
- metadata[key].any? {|v| filter_applies?(key, v, {key => value})}
49
- end
46
+ def filter_applies_to_any_value?(key, value, metadata)
47
+ metadata[key].any? { |v| filter_applies?(key, v, key => value) }
48
+ end
50
49
 
51
- def location_filter_applies?(locations, metadata)
52
- # it ignores location filters for other files
53
- line_number = example_group_declaration_line(locations, metadata)
54
- line_number ? line_number_filter_applies?(line_number, metadata) : true
55
- end
50
+ def location_filter_applies?(locations, metadata)
51
+ # it ignores location filters for other files
52
+ line_number = example_group_declaration_line(locations, metadata)
53
+ line_number ? line_number_filter_applies?(line_number, metadata) : true
54
+ end
56
55
 
57
- def line_number_filter_applies?(line_numbers, metadata)
58
- preceding_declaration_lines = line_numbers.map {|n| RSpec.world.preceding_declaration_line(n)}
59
- !(relevant_line_numbers(metadata) & preceding_declaration_lines).empty?
60
- end
56
+ def line_number_filter_applies?(line_numbers, metadata)
57
+ preceding_declaration_lines = line_numbers.map { |n| RSpec.world.preceding_declaration_line(n) }
58
+ !(relevant_line_numbers(metadata) & preceding_declaration_lines).empty?
59
+ end
61
60
 
62
- def relevant_line_numbers(metadata)
63
- return [] unless metadata
64
- [metadata[:line_number]].compact + (relevant_line_numbers(parent_of metadata))
65
- end
61
+ def relevant_line_numbers(metadata)
62
+ return [] unless metadata
63
+ [metadata[:line_number]].compact + (relevant_line_numbers(parent_of metadata))
64
+ end
66
65
 
67
- def example_group_declaration_line(locations, metadata)
68
- parent = parent_of(metadata)
69
- return nil unless parent
70
- locations[File.expand_path(parent[:file_path])]
71
- end
66
+ def example_group_declaration_line(locations, metadata)
67
+ parent = parent_of(metadata)
68
+ return nil unless parent
69
+ locations[File.expand_path(parent[:file_path])]
70
+ end
72
71
 
73
- def filters_apply?(key, value, metadata)
74
- subhash = metadata[key]
75
- return false unless Hash === subhash || HashImitatable === subhash
76
- value.all? { |k, v| filter_applies?(k, v, subhash) }
77
- end
72
+ def filters_apply?(key, value, metadata)
73
+ subhash = metadata[key]
74
+ return false unless Hash === subhash || HashImitatable === subhash
75
+ value.all? { |k, v| filter_applies?(k, v, subhash) }
76
+ end
78
77
 
79
- def parent_of(metadata)
80
- if metadata.key?(:example_group)
81
- metadata[:example_group]
82
- else
83
- metadata[:parent_example_group]
78
+ def parent_of(metadata)
79
+ if metadata.key?(:example_group)
80
+ metadata[:example_group]
81
+ else
82
+ metadata[:parent_example_group]
83
+ end
84
84
  end
85
- end
86
85
 
87
- def silence_metadata_example_group_deprecations
88
- RSpec.thread_local_metadata[:silence_metadata_example_group_deprecations] = true
89
- yield
90
- ensure
91
- RSpec.thread_local_metadata.delete(:silence_metadata_example_group_deprecations)
86
+ def silence_metadata_example_group_deprecations
87
+ RSpec.thread_local_metadata[:silence_metadata_example_group_deprecations] = true
88
+ yield
89
+ ensure
90
+ RSpec.thread_local_metadata.delete(:silence_metadata_example_group_deprecations)
91
+ end
92
92
  end
93
93
  end
94
94
  end
@@ -2,7 +2,7 @@ begin
2
2
  # Only the minitest 5.x gem includes the minitest.rb and assertions.rb files
3
3
  require 'minitest'
4
4
  require 'minitest/assertions'
5
- rescue LoadError => _ignored
5
+ rescue LoadError
6
6
  # We must be using Ruby Core's MiniTest or the Minitest gem 4.x
7
7
  require 'minitest/unit'
8
8
  Minitest = MiniTest
@@ -10,7 +10,9 @@ module RSpec
10
10
  module Flexmock
11
11
  include ::FlexMock::MockContainer
12
12
 
13
- def self.framework_name; :flexmock end
13
+ def self.framework_name
14
+ :flexmock
15
+ end
14
16
 
15
17
  def setup_mocks_for_rspec
16
18
  # No setup required
@@ -29,7 +29,9 @@ module RSpec
29
29
  module MockingAdapters
30
30
  # @private
31
31
  module Mocha
32
- def self.framework_name; :mocha end
32
+ def self.framework_name
33
+ :mocha
34
+ end
33
35
 
34
36
  # Mocha::Standalone was deprecated as of Mocha 0.9.7.
35
37
  begin
@@ -4,7 +4,9 @@ module RSpec
4
4
  # @private
5
5
  module Null
6
6
  def setup_mocks_for_rspec; end
7
+
7
8
  def verify_mocks_for_rspec; end
9
+
8
10
  def teardown_mocks_for_rspec; end
9
11
  end
10
12
  end
@@ -8,7 +8,9 @@ module RSpec
8
8
  module MockingAdapters
9
9
  # @private
10
10
  module RR
11
- def self.framework_name; :rr end
11
+ def self.framework_name
12
+ :rr
13
+ end
12
14
 
13
15
  include ::RR::Extensions::InstanceMethods
14
16
 
@@ -7,7 +7,9 @@ module RSpec
7
7
  module RSpec
8
8
  include ::RSpec::Mocks::ExampleMethods
9
9
 
10
- def self.framework_name; :rspec end
10
+ def self.framework_name
11
+ :rspec
12
+ end
11
13
 
12
14
  def self.configuration
13
15
  ::RSpec::Mocks.configuration
@@ -1,12 +1,13 @@
1
1
  RSpec::Support.require_rspec_core "formatters/helpers"
2
+ RSpec::Support.require_rspec_support "encoded_string"
2
3
 
3
4
  module RSpec::Core
4
5
  # Notifications are value objects passed to formatters to provide them
5
6
  # with information about a particular event of interest.
6
7
  module Notifications
7
-
8
8
  # @private
9
- class NullColorizer
9
+ module NullColorizer
10
+ module_function
10
11
  def wrap(line, _code_or_symbol)
11
12
  line
12
13
  end
@@ -54,7 +55,6 @@ module RSpec::Core
54
55
  # end
55
56
  #
56
57
  class ExamplesNotification
57
-
58
58
  def initialize(reporter)
59
59
  @reporter = reporter
60
60
  end
@@ -77,18 +77,18 @@ module RSpec::Core
77
77
  # @return [Array(Rspec::Core::Notifications::ExampleNotification]
78
78
  # returns examples as notifications
79
79
  def notifications
80
- @notifications ||= format(examples)
80
+ @notifications ||= format_examples(examples)
81
81
  end
82
82
 
83
83
  # @return [Array(Rspec::Core::Notifications::FailedExampleNotification]
84
84
  # returns failed examples as notifications
85
85
  def failure_notifications
86
- @failed_notifications ||= format(failed_examples)
86
+ @failed_notifications ||= format_examples(failed_examples)
87
87
  end
88
88
 
89
89
  # @return [String] The list of failed examples, fully formatted in the way that
90
90
  # RSpec's built-in formatters emit.
91
- def fully_formatted_failed_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
91
+ def fully_formatted_failed_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
92
92
  formatted = "\nFailures:\n"
93
93
 
94
94
  failure_notifications.each_with_index do |failure, index|
@@ -100,15 +100,15 @@ module RSpec::Core
100
100
 
101
101
  # @return [String] The list of pending examples, fully formatted in the way that
102
102
  # RSpec's built-in formatters emit.
103
- def fully_formatted_pending_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
103
+ def fully_formatted_pending_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
104
104
  formatted = "\nPending:\n"
105
105
 
106
106
  pending_examples.each do |example|
107
107
  formatted_caller = RSpec.configuration.backtrace_formatter.backtrace_line(example.location)
108
108
 
109
109
  formatted <<
110
- " #{colorizer.wrap(example.full_description, :pending)}\n" <<
111
- " # #{colorizer.wrap(example.execution_result.pending_message, :detail)}\n" <<
110
+ " #{colorizer.wrap(example.full_description, :pending)}\n" \
111
+ " # #{colorizer.wrap(example.execution_result.pending_message, :detail)}\n" \
112
112
  " # #{colorizer.wrap(formatted_caller, :detail)}\n"
113
113
  end
114
114
 
@@ -117,12 +117,11 @@ module RSpec::Core
117
117
 
118
118
  private
119
119
 
120
- def format(examples)
120
+ def format_examples(examples)
121
121
  examples.map do |example|
122
122
  ExampleNotification.for(example)
123
123
  end
124
124
  end
125
-
126
125
  end
127
126
 
128
127
  # The `FailedExampleNotification` extends `ExampleNotification` with
@@ -161,7 +160,7 @@ module RSpec::Core
161
160
  #
162
161
  # @param colorizer [#wrap] An object to colorize the message_lines by
163
162
  # @return [Array(String)] The example failure message colorized
164
- def colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
163
+ def colorized_message_lines(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
165
164
  add_shared_group_line(failure_lines, colorizer).map do |line|
166
165
  colorizer.wrap line, RSpec.configuration.failure_color
167
166
  end
@@ -178,7 +177,7 @@ module RSpec::Core
178
177
  #
179
178
  # @param colorizer [#wrap] An object to colorize the message_lines by
180
179
  # @return [Array(String)] the examples colorized backtrace lines
181
- def colorized_formatted_backtrace(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
180
+ def colorized_formatted_backtrace(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
182
181
  formatted_backtrace.map do |backtrace_info|
183
182
  colorizer.wrap "# #{backtrace_info}", RSpec.configuration.detail_color
184
183
  end
@@ -186,15 +185,15 @@ module RSpec::Core
186
185
 
187
186
  # @return [String] The failure information fully formatted in the way that
188
187
  # RSpec's built-in formatters emit.
189
- def fully_formatted(failure_number, colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
188
+ def fully_formatted(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
190
189
  formatted = "\n #{failure_number}) #{description}\n"
191
190
 
192
191
  colorized_message_lines(colorizer).each do |line|
193
- formatted << " #{line}\n"
192
+ formatted << RSpec::Support::EncodedString.new(" #{line}\n", encoding_of(formatted))
194
193
  end
195
194
 
196
195
  colorized_formatted_backtrace(colorizer).each do |line|
197
- formatted << " #{line}\n"
196
+ formatted << RSpec::Support::EncodedString.new(" #{line}\n", encoding_of(formatted))
198
197
  end
199
198
 
200
199
  formatted
@@ -202,13 +201,22 @@ module RSpec::Core
202
201
 
203
202
  private
204
203
 
204
+ if String.method_defined?(:encoding)
205
+ def encoding_of(string)
206
+ string.encoding
207
+ end
208
+ else
209
+ def encoding_of(_string)
210
+ end
211
+ end
212
+
205
213
  def backtrace_formatter
206
214
  RSpec.configuration.backtrace_formatter
207
215
  end
208
216
 
209
217
  def exception_class_name
210
218
  name = exception.class.name.to_s
211
- name ="(anonymous error class)" if name == ''
219
+ name = "(anonymous error class)" if name == ''
212
220
  name
213
221
  end
214
222
 
@@ -238,8 +246,8 @@ module RSpec::Core
238
246
  def shared_group_line
239
247
  @shared_group_line ||=
240
248
  if shared_group
241
- "Shared Example Group: \"#{shared_group.metadata[:shared_group_name]}\"" +
242
- " called from #{backtrace_formatter.backtrace_line(shared_group.location)}"
249
+ "Shared Example Group: \"#{shared_group.metadata[:shared_group_name]}\"" \
250
+ " called from #{backtrace_formatter.backtrace_line(shared_group.location)}"
243
251
  else
244
252
  ""
245
253
  end
@@ -250,7 +258,8 @@ module RSpec::Core
250
258
  end
251
259
 
252
260
  def read_failed_line
253
- unless matching_line = find_failed_line
261
+ matching_line = find_failed_line
262
+ unless matching_line
254
263
  return "Unable to find matching line from backtrace"
255
264
  end
256
265
 
@@ -268,7 +277,7 @@ module RSpec::Core
268
277
 
269
278
  def find_failed_line
270
279
  path = File.expand_path(example.file_path)
271
- exception.backtrace.detect do |line|
280
+ exception.backtrace.find do |line|
272
281
  match = line.match(/(.+?):(\d+)(|:\d+)/)
273
282
  match && match[1].downcase == path.downcase
274
283
  end
@@ -301,7 +310,7 @@ module RSpec::Core
301
310
  #
302
311
  # @param colorizer [#wrap] An object to colorize the message_lines by
303
312
  # @return [Array(String)] The example failure message colorized
304
- def colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
313
+ def colorized_message_lines(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
305
314
  message_lines.map { |line| colorizer.wrap(line, RSpec.configuration.fixed_color) }
306
315
  end
307
316
  end
@@ -391,7 +400,7 @@ module RSpec::Core
391
400
  # @param colorizer [#wrap] An object which supports wrapping text with
392
401
  # specific colors.
393
402
  # @return [String] A colorized results line.
394
- def colorized_totals_line(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
403
+ def colorized_totals_line(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
395
404
  if failure_count > 0
396
405
  colorizer.wrap(totals_line, RSpec.configuration.failure_color)
397
406
  elsif pending_count > 0
@@ -408,7 +417,7 @@ module RSpec::Core
408
417
  # @param colorizer [#wrap] An object which supports wrapping text with
409
418
  # specific colors.
410
419
  # @return [String] A colorized summary line.
411
- def colorized_rerun_commands(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
420
+ def colorized_rerun_commands(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
412
421
  "\nFailed examples:\n\n" +
413
422
  failed_examples.map do |example|
414
423
  colorizer.wrap("rspec #{example.location}", RSpec.configuration.failure_color) + " " +
@@ -429,7 +438,7 @@ module RSpec::Core
429
438
 
430
439
  # @return [String] The summary information fully formatted in the way that
431
440
  # RSpec's built-in formatters emit.
432
- def fully_formatted(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
441
+ def fully_formatted(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
433
442
  formatted = "\nFinished in #{formatted_duration} " \
434
443
  "(files took #{formatted_load_time} to load)\n" \
435
444
  "#{colorized_totals_line(colorizer)}\n"
@@ -492,9 +501,8 @@ module RSpec::Core
492
501
  location_hash = example_groups[location] ||= Hash.new(0)
493
502
  location_hash[:total_time] += example.execution_result.run_time
494
503
  location_hash[:count] += 1
495
- unless location_hash.has_key?(:description)
496
- location_hash[:description] = example.example_group.top_level_description
497
- end
504
+ next if location_hash.key?(:description)
505
+ location_hash[:description] = example.example_group.top_level_description
498
506
  end
499
507
 
500
508
  # stop if we've only one example group
@@ -530,6 +538,5 @@ module RSpec::Core
530
538
  # currently require no information, but we may wish to extend in future.
531
539
  class NullNotification
532
540
  end
533
-
534
541
  end
535
542
  end
@@ -11,7 +11,7 @@ module RSpec::Core
11
11
  def parse(args)
12
12
  return {} if args.empty?
13
13
 
14
- options = args.delete('--tty') ? {:tty => true} : {}
14
+ options = args.delete('--tty') ? { :tty => true } : {}
15
15
  begin
16
16
  parser(options).parse!(args)
17
17
  rescue OptionParser::InvalidOption => e
@@ -51,11 +51,11 @@ module RSpec::Core
51
51
  options[:order] = "rand:#{seed}"
52
52
  end
53
53
 
54
- parser.on('--fail-fast', 'Abort the run on first failure.') do |o|
54
+ parser.on('--fail-fast', 'Abort the run on first failure.') do |_o|
55
55
  options[:fail_fast] = true
56
56
  end
57
57
 
58
- parser.on('--no-fail-fast', 'Do not abort the run on first failure.') do |o|
58
+ parser.on('--no-fail-fast', 'Do not abort the run on first failure.') do |_o|
59
59
  options[:fail_fast] = false
60
60
  end
61
61
 
@@ -64,7 +64,7 @@ module RSpec::Core
64
64
  end
65
65
 
66
66
  parser.on('--dry-run', 'Print the formatter output of your suite without',
67
- ' running any examples or hooks') do |o|
67
+ ' running any examples or hooks') do |_o|
68
68
  options[:dry_run] = true
69
69
  end
70
70
 
@@ -76,7 +76,7 @@ module RSpec::Core
76
76
  options[:drb_port] = o.to_i
77
77
  end
78
78
 
79
- parser.on('--init', 'Initialize your project with RSpec.') do |cmd|
79
+ parser.on('--init', 'Initialize your project with RSpec.') do |_cmd|
80
80
  RSpec::Support.require_rspec_core "project_initializer"
81
81
  ProjectInitializer.new.run
82
82
  exit
@@ -85,11 +85,11 @@ module RSpec::Core
85
85
  parser.separator("\n **** Output ****\n\n")
86
86
 
87
87
  parser.on('-f', '--format FORMATTER', 'Choose a formatter.',
88
- ' [p]rogress (default - dots)',
89
- ' [d]ocumentation (group and example names)',
90
- ' [h]tml',
91
- ' [j]son',
92
- ' custom formatter class name') do |o|
88
+ ' [p]rogress (default - dots)',
89
+ ' [d]ocumentation (group and example names)',
90
+ ' [h]tml',
91
+ ' [j]son',
92
+ ' custom formatter class name') do |o|
93
93
  options[:formatters] ||= []
94
94
  options[:formatters] << [o]
95
95
  end
@@ -107,7 +107,7 @@ module RSpec::Core
107
107
  options[:deprecation_stream] = file
108
108
  end
109
109
 
110
- parser.on('-b', '--backtrace', 'Enable full backtrace.') do |o|
110
+ parser.on('-b', '--backtrace', 'Enable full backtrace.') do |_o|
111
111
  options[:full_backtrace] = true
112
112
  end
113
113
 
@@ -124,10 +124,10 @@ module RSpec::Core
124
124
  begin
125
125
  Integer(argument)
126
126
  rescue ArgumentError
127
- RSpec.warning "Non integer specified as profile count, seperate " +
128
- "your path from options with -- e.g. " +
127
+ RSpec.warning "Non integer specified as profile count, seperate " \
128
+ "your path from options with -- e.g. " \
129
129
  "`rspec --profile -- #{argument}`",
130
- :call_site => nil
130
+ :call_site => nil
131
131
  true
132
132
  end
133
133
  end
@@ -153,8 +153,12 @@ FILTERING
153
153
  options[:pattern] = o
154
154
  end
155
155
 
156
+ parser.on('--exclude-pattern PATTERN', 'Load files except those matching pattern. Opposite effect of --pattern.') do |o|
157
+ options[:exclude_pattern] = o
158
+ end
159
+
156
160
  parser.on('-e', '--example STRING', "Run examples whose full nested names include STRING (may be",
157
- " used more than once)") do |o|
161
+ " used more than once)") do |o|
158
162
  (options[:full_description] ||= []) << Regexp.compile(Regexp.escape(o))
159
163
  end
160
164
 
@@ -165,25 +169,25 @@ FILTERING
165
169
  ' - TAG is always converted to a symbol') do |tag|
166
170
  filter_type = tag =~ /^~/ ? :exclusion_filter : :inclusion_filter
167
171
 
168
- name,value = tag.gsub(/^(~@|~|@)/, '').split(':',2)
172
+ name, value = tag.gsub(/^(~@|~|@)/, '').split(':', 2)
169
173
  name = name.to_sym
170
174
 
171
175
  options[filter_type] ||= {}
172
176
  options[filter_type][name] = case value
173
- when nil then true # The default value for tags is true
174
- when 'true' then true
175
- when 'false' then false
176
- when 'nil' then nil
177
- when /^:/ then value[1..-1].to_sym
178
- when /^\d+$/ then Integer(value)
179
- when /^\d+.\d+$/ then Float(value)
177
+ when nil then true # The default value for tags is true
178
+ when 'true' then true
179
+ when 'false' then false
180
+ when 'nil' then nil
181
+ when /^:/ then value[1..-1].to_sym
182
+ when /^\d+$/ then Integer(value)
183
+ when /^\d+.\d+$/ then Float(value)
180
184
  else
181
185
  value
182
186
  end
183
187
  end
184
188
 
185
189
  parser.on('--default-path PATH', 'Set the default path where RSpec looks for examples (can',
186
- ' be a path to a file or a directory).') do |path|
190
+ ' be a path to a file or a directory).') do |path|
187
191
  options[:default_path] = path
188
192
  end
189
193
 
@@ -201,7 +205,7 @@ FILTERING
201
205
 
202
206
  parser.on_tail('-h', '--help', "You're looking at it.") do
203
207
  # removing the blank invalid options from the output
204
- puts parser.to_s.gsub(/^\s+(#{invalid_options.join('|')})\s*$\n/,'')
208
+ puts parser.to_s.gsub(/^\s+(#{invalid_options.join('|')})\s*$\n/, '')
205
209
  exit
206
210
  end
207
211