rspec-core 3.0.4 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +67 -0
- data/lib/rspec/core.rb +3 -1
- data/lib/rspec/core/backtrace_formatter.rb +13 -10
- data/lib/rspec/core/configuration.rb +123 -57
- data/lib/rspec/core/configuration_options.rb +12 -12
- data/lib/rspec/core/drb.rb +11 -11
- data/lib/rspec/core/dsl.rb +0 -1
- data/lib/rspec/core/example.rb +39 -12
- data/lib/rspec/core/example_group.rb +31 -98
- data/lib/rspec/core/filter_manager.rb +16 -17
- data/lib/rspec/core/formatters.rb +14 -13
- data/lib/rspec/core/formatters/base_formatter.rb +8 -113
- data/lib/rspec/core/formatters/base_text_formatter.rb +3 -5
- data/lib/rspec/core/formatters/console_codes.rb +1 -2
- data/lib/rspec/core/formatters/deprecation_formatter.rb +2 -3
- data/lib/rspec/core/formatters/documentation_formatter.rb +3 -4
- data/lib/rspec/core/formatters/helpers.rb +5 -6
- data/lib/rspec/core/formatters/html_formatter.rb +20 -19
- data/lib/rspec/core/formatters/html_printer.rb +6 -5
- data/lib/rspec/core/formatters/json_formatter.rb +3 -2
- data/lib/rspec/core/formatters/profile_formatter.rb +0 -2
- data/lib/rspec/core/formatters/progress_formatter.rb +4 -4
- data/lib/rspec/core/formatters/protocol.rb +163 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +7 -6
- data/lib/rspec/core/hooks.rb +25 -10
- data/lib/rspec/core/memoized_helpers.rb +7 -5
- data/lib/rspec/core/metadata.rb +29 -30
- data/lib/rspec/core/metadata_filter.rb +66 -66
- data/lib/rspec/core/minitest_assertions_adapter.rb +1 -1
- data/lib/rspec/core/mocking_adapters/flexmock.rb +3 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +3 -1
- data/lib/rspec/core/mocking_adapters/null.rb +2 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +3 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +3 -1
- data/lib/rspec/core/notifications.rb +36 -29
- data/lib/rspec/core/option_parser.rb +29 -25
- data/lib/rspec/core/ordering.rb +8 -9
- data/lib/rspec/core/pending.rb +6 -8
- data/lib/rspec/core/project_initializer.rb +4 -2
- data/lib/rspec/core/project_initializer/.rspec +0 -1
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +37 -26
- data/lib/rspec/core/rake_task.rb +37 -19
- data/lib/rspec/core/reporter.rb +13 -16
- data/lib/rspec/core/ruby_project.rb +2 -2
- data/lib/rspec/core/runner.rb +11 -14
- data/lib/rspec/core/shared_example_group.rb +14 -13
- data/lib/rspec/core/test_unit_assertions_adapter.rb +1 -1
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/warnings.rb +4 -4
- data/lib/rspec/core/world.rb +22 -24
- metadata +6 -5
- 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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
# @private
|
16
|
+
def all_apply?(filters, metadata)
|
17
|
+
filters.all? { |k, v| filter_applies?(k, v, metadata) }
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
27
|
+
return false unless metadata.key?(key)
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
44
|
+
private
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
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
|
@@ -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
|
-
|
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 ||=
|
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 ||=
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
-
|
242
|
-
|
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
|
-
|
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.
|
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
|
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
|
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
|
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
|
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
|
-
|
496
|
-
|
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 |
|
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 |
|
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 |
|
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 |
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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 |
|
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
|
-
|
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
|
-
|
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
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
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
|
-
|
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
|
|