rspec-core 2.6.0 → 2.7.0.rc1
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.
- data/README.md +1 -1
- data/features/Upgrade.md +11 -0
- data/features/command_line/exit_status.feature +20 -3
- data/features/command_line/format_option.feature +8 -0
- data/features/command_line/line_number_appended_to_path.feature +35 -1
- data/features/command_line/line_number_option.feature +16 -3
- data/features/command_line/pattern_option.feature +31 -0
- data/features/command_line/rake_task.feature +1 -1
- data/features/command_line/ruby.feature +22 -0
- data/features/configuration/default_path.feature +38 -0
- data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
- data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
- data/features/filtering/inclusion_filters.feature +4 -5
- data/features/formatters/text_formatter.feature +16 -13
- data/features/helper_methods/let.feature +4 -4
- data/features/hooks/around_hooks.feature +1 -1
- data/features/hooks/before_and_after_hooks.feature +3 -3
- data/features/hooks/filtering.feature +13 -6
- data/features/metadata/user_defined.feature +12 -10
- data/features/pending/pending_examples.feature +21 -8
- data/features/step_definitions/additional_cli_steps.rb +1 -1
- data/features/subject/attribute_of_subject.feature +2 -2
- data/features/support/env.rb +1 -2
- data/lib/rspec/core/backward_compatibility.rb +1 -1
- data/lib/rspec/core/configuration.rb +71 -16
- data/lib/rspec/core/configuration_options.rb +46 -16
- data/lib/rspec/core/{extensions/object.rb → dsl.rb} +2 -4
- data/lib/rspec/core/example.rb +10 -7
- data/lib/rspec/core/example_group.rb +34 -18
- data/lib/rspec/core/expecting/with_rspec.rb +0 -2
- data/lib/rspec/core/extensions.rb +0 -1
- data/lib/rspec/core/formatters/base_formatter.rb +8 -4
- data/lib/rspec/core/formatters/base_text_formatter.rb +38 -18
- data/lib/rspec/core/formatters/html_formatter.rb +3 -1
- data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
- data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
- data/lib/rspec/core/hooks.rb +7 -6
- data/lib/rspec/core/let.rb +5 -5
- data/lib/rspec/core/metadata.rb +136 -94
- data/lib/rspec/core/metadata_hash_builder.rb +1 -1
- data/lib/rspec/core/option_parser.rb +11 -7
- data/lib/rspec/core/pending.rb +2 -1
- data/lib/rspec/core/rake_task.rb +26 -15
- data/lib/rspec/core/reporter.rb +5 -6
- data/lib/rspec/core/runner.rb +1 -1
- data/lib/rspec/core/shared_example_group.rb +4 -4
- data/lib/rspec/core/subject.rb +7 -7
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +9 -13
- data/lib/rspec/core.rb +14 -21
- data/spec/autotest/discover_spec.rb +2 -2
- data/spec/autotest/failed_results_re_spec.rb +29 -21
- data/spec/autotest/rspec_spec.rb +3 -3
- data/spec/rspec/core/command_line_spec.rb +1 -6
- data/spec/rspec/core/configuration_options_spec.rb +111 -27
- data/spec/rspec/core/configuration_spec.rb +161 -37
- data/spec/rspec/core/deprecations_spec.rb +2 -2
- data/spec/rspec/core/drb_command_line_spec.rb +6 -6
- data/spec/rspec/core/example_group_spec.rb +197 -61
- data/spec/rspec/core/example_spec.rb +33 -16
- data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +222 -71
- data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +90 -26
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
- data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
- data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +91 -27
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
- data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
- data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
- data/spec/rspec/core/let_spec.rb +19 -6
- data/spec/rspec/core/metadata_spec.rb +146 -61
- data/spec/rspec/core/pending_example_spec.rb +4 -4
- data/spec/rspec/core/rake_task_spec.rb +71 -50
- data/spec/rspec/core/reporter_spec.rb +2 -2
- data/spec/rspec/core/ruby_project_spec.rb +2 -2
- data/spec/rspec/core/runner_spec.rb +4 -1
- data/spec/rspec/core/shared_example_group_spec.rb +15 -119
- data/spec/rspec/core/subject_spec.rb +13 -13
- data/spec/rspec/core/world_spec.rb +31 -22
- data/spec/rspec/core_spec.rb +1 -29
- data/spec/spec_helper.rb +51 -50
- data/spec/support/shared_example_groups.rb +3 -3
- data/spec/support/spec_files.rb +8 -8
- metadata +79 -94
- data/.document +0 -5
- data/.gitignore +0 -12
- data/.rspec +0 -0
- data/.travis.yml +0 -7
- data/Gemfile +0 -50
- data/Guardfile +0 -5
- data/License.txt +0 -23
- data/Rakefile +0 -89
- data/cucumber.yml +0 -2
- data/features/.nav +0 -57
- data/features/Changelog.md +0 -269
- data/rspec-core.gemspec +0 -24
- data/script/FullBuildRakeFile +0 -63
- data/script/console +0 -8
- data/script/cucumber +0 -1
- data/script/full_build +0 -1
- data/script/spec +0 -1
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
- data/spec.txt +0 -1126
- /data/{bin → exe}/autospec +0 -0
- /data/{bin → exe}/rspec +0 -0
|
@@ -77,22 +77,35 @@ Feature: pending examples
|
|
|
77
77
|
And the output should contain "Expected pending 'something else getting finished' to fail. No Error was raised."
|
|
78
78
|
And the output should contain "pending_with_passing_block_spec.rb:3"
|
|
79
79
|
|
|
80
|
-
Scenario: temporarily pending by
|
|
81
|
-
Given a file named "
|
|
80
|
+
Scenario: temporarily pending by prefixing `it`, `specify`, or `example` with an x
|
|
81
|
+
Given a file named "temporarily_pending_spec.rb" with:
|
|
82
82
|
"""
|
|
83
83
|
describe "an example" do
|
|
84
84
|
xit "is pending using xit" do
|
|
85
|
-
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
xspecify "is pending using xspecify" do
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
xexample "is pending using xexample" do
|
|
86
91
|
end
|
|
87
92
|
end
|
|
88
93
|
"""
|
|
89
|
-
When I run `rspec
|
|
94
|
+
When I run `rspec temporarily_pending_spec.rb`
|
|
90
95
|
Then the exit status should be 0
|
|
91
|
-
And the output should contain "
|
|
96
|
+
And the output should contain "3 examples, 0 failures, 3 pending"
|
|
92
97
|
And the output should contain:
|
|
93
98
|
"""
|
|
94
99
|
Pending:
|
|
95
100
|
an example is pending using xit
|
|
101
|
+
# Not Yet Implemented
|
|
102
|
+
# ./temporarily_pending_spec.rb:2
|
|
103
|
+
an example is pending using xspecify
|
|
104
|
+
# Not Yet Implemented
|
|
105
|
+
# ./temporarily_pending_spec.rb:5
|
|
106
|
+
an example is pending using xexample
|
|
107
|
+
# Not Yet Implemented
|
|
108
|
+
# ./temporarily_pending_spec.rb:8
|
|
96
109
|
"""
|
|
97
110
|
|
|
98
111
|
Scenario: example with no docstring and pending method using documentation formatter
|
|
@@ -100,7 +113,7 @@ Feature: pending examples
|
|
|
100
113
|
"""
|
|
101
114
|
describe "an example" do
|
|
102
115
|
it "checks something" do
|
|
103
|
-
(3+4).should
|
|
116
|
+
(3+4).should eq(7)
|
|
104
117
|
end
|
|
105
118
|
specify do
|
|
106
119
|
pending
|
|
@@ -122,10 +135,10 @@ Feature: pending examples
|
|
|
122
135
|
"""
|
|
123
136
|
describe "an example" do
|
|
124
137
|
it "checks something" do
|
|
125
|
-
(3+4).should
|
|
138
|
+
(3+4).should eq(7)
|
|
126
139
|
end
|
|
127
140
|
pending do
|
|
128
|
-
"string".reverse.should
|
|
141
|
+
"string".reverse.should eq("gnirts")
|
|
129
142
|
end
|
|
130
143
|
end
|
|
131
144
|
"""
|
|
@@ -34,7 +34,7 @@ Feature: attribute of subject
|
|
|
34
34
|
Array
|
|
35
35
|
when first created
|
|
36
36
|
size
|
|
37
|
-
should
|
|
37
|
+
should eq 0
|
|
38
38
|
"""
|
|
39
39
|
|
|
40
40
|
Scenario: specify value of a nested attribute
|
|
@@ -65,7 +65,7 @@ Feature: attribute of subject
|
|
|
65
65
|
Person
|
|
66
66
|
with one phone number (555-1212)
|
|
67
67
|
phone_numbers.first
|
|
68
|
-
should
|
|
68
|
+
should eq 555-1212
|
|
69
69
|
"""
|
|
70
70
|
|
|
71
71
|
Scenario: specify value of an attribute of a hash
|
data/features/support/env.rb
CHANGED
|
@@ -13,7 +13,7 @@ be removed from a future version of RSpec.
|
|
|
13
13
|
|
|
14
14
|
* #{name} is deprecated.
|
|
15
15
|
* RSpec is the new top-level module in RSpec-2
|
|
16
|
-
|
|
16
|
+
*****************************************************************
|
|
17
17
|
WARNING
|
|
18
18
|
RSpec
|
|
19
19
|
else
|
|
@@ -6,6 +6,8 @@ module RSpec
|
|
|
6
6
|
class Configuration
|
|
7
7
|
include RSpec::Core::Hooks
|
|
8
8
|
|
|
9
|
+
class MustBeConfiguredBeforeExampleGroupsError < StandardError; end
|
|
10
|
+
|
|
9
11
|
def self.add_setting(name, opts={})
|
|
10
12
|
if opts[:alias]
|
|
11
13
|
alias_method name, opts[:alias]
|
|
@@ -38,6 +40,8 @@ module RSpec
|
|
|
38
40
|
add_setting :tty
|
|
39
41
|
add_setting :treat_symbols_as_metadata_keys_with_true_values, :default => false
|
|
40
42
|
add_setting :expecting_with_rspec
|
|
43
|
+
add_setting :default_path, :default => 'spec'
|
|
44
|
+
add_setting :show_failures_in_pending_blocks, :default => false
|
|
41
45
|
|
|
42
46
|
CONDITIONAL_FILTERS = {
|
|
43
47
|
:if => lambda { |value, metadata| metadata.has_key?(:if) && !value },
|
|
@@ -46,6 +50,7 @@ module RSpec
|
|
|
46
50
|
|
|
47
51
|
DEFAULT_BACKTRACE_PATTERNS = [
|
|
48
52
|
/\/lib\d*\/ruby\//,
|
|
53
|
+
/org\/jruby\//,
|
|
49
54
|
/bin\//,
|
|
50
55
|
/gems/,
|
|
51
56
|
/spec\/spec_helper\.rb/,
|
|
@@ -62,6 +67,7 @@ module RSpec
|
|
|
62
67
|
|
|
63
68
|
def reset
|
|
64
69
|
@reporter = nil
|
|
70
|
+
@formatters.clear if @formatters
|
|
65
71
|
end
|
|
66
72
|
|
|
67
73
|
# :call-seq:
|
|
@@ -158,6 +164,7 @@ module RSpec
|
|
|
158
164
|
# teardown_mocks_for_rspec
|
|
159
165
|
# - called after verify_mocks_for_rspec (even if there are errors)
|
|
160
166
|
def mock_framework=(framework)
|
|
167
|
+
assert_no_example_groups_defined(:mock_framework)
|
|
161
168
|
case framework
|
|
162
169
|
when Module
|
|
163
170
|
settings[:mock_framework] = framework
|
|
@@ -198,6 +205,7 @@ module RSpec
|
|
|
198
205
|
# Given :stdlib, configures test/unit/assertions
|
|
199
206
|
# Given both, configures both
|
|
200
207
|
def expect_with(*frameworks)
|
|
208
|
+
assert_no_example_groups_defined(:expect_with)
|
|
201
209
|
settings[:expectation_frameworks] = []
|
|
202
210
|
frameworks.each do |framework|
|
|
203
211
|
case framework
|
|
@@ -252,22 +260,34 @@ module RSpec
|
|
|
252
260
|
begin
|
|
253
261
|
require 'ruby-debug'
|
|
254
262
|
Debugger.start
|
|
255
|
-
rescue LoadError
|
|
263
|
+
rescue LoadError => e
|
|
256
264
|
raise <<-EOM
|
|
257
265
|
|
|
258
266
|
#{'*'*50}
|
|
259
|
-
|
|
267
|
+
#{e.message}
|
|
268
|
+
|
|
269
|
+
If you have it installed as a ruby gem, then you need to either require
|
|
270
|
+
'rubygems' or configure the RUBYOPT environment variable with the value
|
|
271
|
+
'rubygems'.
|
|
260
272
|
|
|
261
|
-
|
|
262
|
-
require 'rubygems' or configure the RUBYOPT environment variable with
|
|
263
|
-
the value 'rubygems'.
|
|
273
|
+
#{e.backtrace.join("\n")}
|
|
264
274
|
#{'*'*50}
|
|
265
275
|
EOM
|
|
266
276
|
end
|
|
267
277
|
end
|
|
268
278
|
|
|
269
|
-
|
|
270
|
-
|
|
279
|
+
# Run examples defined on +line_numbers+ in all files to run.
|
|
280
|
+
def line_numbers=(line_numbers)
|
|
281
|
+
filter_run({ :line_numbers => line_numbers.map{|l| l.to_i} }, true)
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def add_location(file_path, line_numbers)
|
|
285
|
+
# Filter locations is a hash of expanded paths to arrays of line numbers
|
|
286
|
+
# to match against.
|
|
287
|
+
#
|
|
288
|
+
filter_locations = ((self.filter || {})[:locations] ||= {})
|
|
289
|
+
(filter_locations[File.expand_path(file_path)] ||= []).push(*line_numbers)
|
|
290
|
+
filter_run({ :locations => filter_locations })
|
|
271
291
|
end
|
|
272
292
|
|
|
273
293
|
def full_description=(description)
|
|
@@ -297,15 +317,31 @@ EOM
|
|
|
297
317
|
end
|
|
298
318
|
|
|
299
319
|
def files_or_directories_to_run=(*files)
|
|
300
|
-
|
|
320
|
+
files = files.flatten
|
|
321
|
+
files << default_path if command == 'rspec' && default_path && files.empty?
|
|
322
|
+
self.files_to_run = get_files_to_run(files)
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
def command
|
|
326
|
+
$0.split(File::SEPARATOR).last
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def get_files_to_run(files)
|
|
330
|
+
patterns = pattern.split(",")
|
|
331
|
+
files.map do |file|
|
|
301
332
|
if File.directory?(file)
|
|
302
|
-
|
|
303
|
-
|
|
333
|
+
patterns.map do |pattern|
|
|
334
|
+
if pattern =~ /^#{file}/
|
|
335
|
+
Dir[pattern.strip]
|
|
336
|
+
else
|
|
337
|
+
Dir["#{file}/{#{pattern.strip}}"]
|
|
338
|
+
end
|
|
304
339
|
end
|
|
305
340
|
else
|
|
306
|
-
if file =~
|
|
307
|
-
|
|
308
|
-
|
|
341
|
+
if file =~ /^(.*?)((?:\:\d+)+)$/
|
|
342
|
+
path, lines = $1, $2[1..-1].split(":").map{|n| n.to_i}
|
|
343
|
+
add_location path, lines
|
|
344
|
+
path
|
|
309
345
|
else
|
|
310
346
|
file
|
|
311
347
|
end
|
|
@@ -345,14 +381,24 @@ EOM
|
|
|
345
381
|
RSpec::Core::ExampleGroup.alias_it_should_behave_like_to(new_name, report_label)
|
|
346
382
|
end
|
|
347
383
|
|
|
384
|
+
undef_method :exclusion_filter=
|
|
348
385
|
def exclusion_filter=(filter)
|
|
349
386
|
settings[:exclusion_filter] = filter
|
|
350
387
|
end
|
|
351
388
|
|
|
389
|
+
undef_method :exclusion_filter
|
|
390
|
+
def exclusion_filter
|
|
391
|
+
settings[:exclusion_filter] || {}
|
|
392
|
+
end
|
|
393
|
+
|
|
352
394
|
def inclusion_filter=(filter)
|
|
353
395
|
settings[:inclusion_filter] = filter
|
|
354
396
|
end
|
|
355
397
|
|
|
398
|
+
def inclusion_filter
|
|
399
|
+
settings[:inclusion_filter] || {}
|
|
400
|
+
end
|
|
401
|
+
|
|
356
402
|
def filter_run_including(*args)
|
|
357
403
|
force_overwrite = if args.last.is_a?(Hash) || args.last.is_a?(Symbol)
|
|
358
404
|
false
|
|
@@ -362,7 +408,7 @@ EOM
|
|
|
362
408
|
|
|
363
409
|
options = build_metadata_hash_from(args)
|
|
364
410
|
|
|
365
|
-
if inclusion_filter and inclusion_filter[:
|
|
411
|
+
if inclusion_filter and inclusion_filter[:line_numbers] || inclusion_filter[:full_description]
|
|
366
412
|
warn "Filtering by #{options.inspect} is not possible since " \
|
|
367
413
|
"you are already filtering by #{inclusion_filter.inspect}"
|
|
368
414
|
else
|
|
@@ -393,7 +439,7 @@ EOM
|
|
|
393
439
|
|
|
394
440
|
def configure_group(group)
|
|
395
441
|
include_or_extend_modules.each do |include_or_extend, mod, filters|
|
|
396
|
-
next unless filters.empty? || group.
|
|
442
|
+
next unless filters.empty? || group.any_apply?(filters)
|
|
397
443
|
group.send(include_or_extend, mod)
|
|
398
444
|
end
|
|
399
445
|
end
|
|
@@ -415,6 +461,15 @@ EOM
|
|
|
415
461
|
|
|
416
462
|
private
|
|
417
463
|
|
|
464
|
+
def assert_no_example_groups_defined(config_option)
|
|
465
|
+
if RSpec.world.example_groups.any?
|
|
466
|
+
raise MustBeConfiguredBeforeExampleGroupsError.new(
|
|
467
|
+
"RSpec's #{config_option} configuration option must be configured before " +
|
|
468
|
+
"any example groups are defined, but you have already defined a group."
|
|
469
|
+
)
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
|
|
418
473
|
def raise_if_rspec_1_is_loaded
|
|
419
474
|
if defined?(Spec) && defined?(Spec::VERSION::MAJOR) && Spec::VERSION::MAJOR == 1
|
|
420
475
|
raise <<-MESSAGE
|
|
@@ -468,7 +523,7 @@ MESSAGE
|
|
|
468
523
|
end
|
|
469
524
|
end
|
|
470
525
|
end
|
|
471
|
-
|
|
526
|
+
|
|
472
527
|
def string_const?(str)
|
|
473
528
|
str.is_a?(String) && /\A[A-Z][a-zA-Z0-9_:]*\z/ =~ str
|
|
474
529
|
end
|
|
@@ -2,9 +2,6 @@ module RSpec
|
|
|
2
2
|
module Core
|
|
3
3
|
|
|
4
4
|
class ConfigurationOptions
|
|
5
|
-
LOCAL_OPTIONS_FILE = ".rspec"
|
|
6
|
-
GLOBAL_OPTIONS_FILE = File.join(File.expand_path("~"), ".rspec")
|
|
7
|
-
|
|
8
5
|
attr_reader :options
|
|
9
6
|
|
|
10
7
|
def initialize(args)
|
|
@@ -12,18 +9,17 @@ module RSpec
|
|
|
12
9
|
end
|
|
13
10
|
|
|
14
11
|
def configure(config)
|
|
15
|
-
keys = options.keys
|
|
16
|
-
|
|
17
|
-
keys.unshift(:libs) if keys.delete(:libs)
|
|
12
|
+
keys = order(options.keys, :libs, :requires, :default_path, :pattern)
|
|
13
|
+
|
|
18
14
|
formatters = options[:formatters] if keys.delete(:formatters)
|
|
15
|
+
|
|
16
|
+
config.exclusion_filter.merge! options[:exclusion_filter] if keys.delete(:exclusion_filter)
|
|
17
|
+
|
|
19
18
|
keys.each do |key|
|
|
20
19
|
config.send("#{key}=", options[key]) if config.respond_to?("#{key}=")
|
|
21
20
|
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
config.add_formatter(*pair)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
21
|
+
|
|
22
|
+
formatters.each {|pair| config.add_formatter(*pair) } if formatters
|
|
27
23
|
end
|
|
28
24
|
|
|
29
25
|
def drb_argv
|
|
@@ -33,14 +29,27 @@ module RSpec
|
|
|
33
29
|
argv << "--backtrace" if options[:full_backtrace]
|
|
34
30
|
argv << "--tty" if options[:tty]
|
|
35
31
|
argv << "--fail-fast" if options[:fail_fast]
|
|
36
|
-
argv << "--line_number" << options[:line_number] if options[:line_number]
|
|
37
32
|
argv << "--options" << options[:custom_options_file] if options[:custom_options_file]
|
|
38
|
-
|
|
33
|
+
if options[:full_description]
|
|
34
|
+
# The argument to --example is regexp-escaped before being stuffed
|
|
35
|
+
# into a regexp when received for the first time (see OptionParser).
|
|
36
|
+
# Hence, merely grabbing the source of this regexp will retain the
|
|
37
|
+
# backslashes, so we must remove them.
|
|
38
|
+
argv << "--example" << options[:full_description].source.delete('\\')
|
|
39
|
+
end
|
|
40
|
+
if options[:line_numbers]
|
|
41
|
+
argv += options[:line_numbers].inject([]){|a,l| a << "--line_number" << l}
|
|
42
|
+
end
|
|
39
43
|
if options[:filter]
|
|
40
44
|
options[:filter].each_pair do |k, v|
|
|
41
45
|
argv << "--tag" << k.to_s
|
|
42
46
|
end
|
|
43
47
|
end
|
|
48
|
+
if options[:exclusion_filter]
|
|
49
|
+
options[:exclusion_filter].each_pair do |k, v|
|
|
50
|
+
argv << "--tag" << "~#{k.to_s}"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
44
53
|
if options[:formatters]
|
|
45
54
|
options[:formatters].each do |pair|
|
|
46
55
|
argv << "--format" << pair[0]
|
|
@@ -62,6 +71,13 @@ module RSpec
|
|
|
62
71
|
|
|
63
72
|
private
|
|
64
73
|
|
|
74
|
+
def order(keys, *ordered)
|
|
75
|
+
ordered.reverse.each do |key|
|
|
76
|
+
keys.unshift(key) if keys.delete(key)
|
|
77
|
+
end
|
|
78
|
+
keys
|
|
79
|
+
end
|
|
80
|
+
|
|
65
81
|
def file_options
|
|
66
82
|
custom_options_file ? custom_options : global_options.merge(local_options)
|
|
67
83
|
end
|
|
@@ -79,11 +95,11 @@ module RSpec
|
|
|
79
95
|
end
|
|
80
96
|
|
|
81
97
|
def local_options
|
|
82
|
-
@local_options ||= options_from(
|
|
98
|
+
@local_options ||= options_from(local_options_file)
|
|
83
99
|
end
|
|
84
100
|
|
|
85
101
|
def global_options
|
|
86
|
-
@global_options ||= options_from(
|
|
102
|
+
@global_options ||= options_from(global_options_file)
|
|
87
103
|
end
|
|
88
104
|
|
|
89
105
|
def options_from(path)
|
|
@@ -91,7 +107,7 @@ module RSpec
|
|
|
91
107
|
end
|
|
92
108
|
|
|
93
109
|
def args_from_options_file(path)
|
|
94
|
-
return [] unless File.exist?(path)
|
|
110
|
+
return [] unless path && File.exist?(path)
|
|
95
111
|
config_string = options_file_as_erb_string(path)
|
|
96
112
|
config_string.split(/\n+/).map {|l| l.split}.flatten
|
|
97
113
|
end
|
|
@@ -104,6 +120,20 @@ module RSpec
|
|
|
104
120
|
def custom_options_file
|
|
105
121
|
command_line_options[:custom_options_file]
|
|
106
122
|
end
|
|
123
|
+
|
|
124
|
+
def local_options_file
|
|
125
|
+
".rspec"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def global_options_file
|
|
129
|
+
begin
|
|
130
|
+
File.join(File.expand_path("~"), ".rspec")
|
|
131
|
+
rescue ArgumentError
|
|
132
|
+
warn "Unable to find ~/.rspec because the HOME environment variable is not set"
|
|
133
|
+
nil
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
107
137
|
end
|
|
108
138
|
end
|
|
109
139
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module RSpec
|
|
2
2
|
module Core
|
|
3
|
-
module
|
|
3
|
+
module DSL
|
|
4
4
|
def describe(*args, &example_group_block)
|
|
5
5
|
RSpec::Core::ExampleGroup.describe(*args, &example_group_block).register
|
|
6
6
|
end
|
|
@@ -8,6 +8,4 @@ module RSpec
|
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
include RSpec::Core::ObjectExtensions
|
|
13
|
-
end
|
|
11
|
+
include RSpec::Core::DSL
|
data/lib/rspec/core/example.rb
CHANGED
|
@@ -4,6 +4,10 @@ module RSpec
|
|
|
4
4
|
|
|
5
5
|
attr_reader :metadata, :options, :example_group_instance
|
|
6
6
|
|
|
7
|
+
# Returns the first exception raised, if any, in the context of running
|
|
8
|
+
# this example.
|
|
9
|
+
attr_reader :exception
|
|
10
|
+
|
|
7
11
|
def self.delegate_to_metadata(*keys)
|
|
8
12
|
keys.each do |key|
|
|
9
13
|
define_method(key) {@metadata[key]}
|
|
@@ -23,13 +27,12 @@ module RSpec
|
|
|
23
27
|
@example_group_class
|
|
24
28
|
end
|
|
25
29
|
|
|
26
|
-
def around_hooks
|
|
30
|
+
def around_hooks # :nodoc:
|
|
27
31
|
@around_hooks ||= example_group.around_hooks_for(self)
|
|
28
32
|
end
|
|
29
33
|
|
|
30
|
-
def
|
|
31
|
-
@metadata.
|
|
32
|
-
@example_group_class.apply?(predicate, filters)
|
|
34
|
+
def all_apply?(filters)
|
|
35
|
+
@metadata.all_apply?(filters) || @example_group_class.all_apply?(filters)
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
alias_method :pending?, :pending
|
|
@@ -106,7 +109,7 @@ module RSpec
|
|
|
106
109
|
if around_hooks.empty?
|
|
107
110
|
yield
|
|
108
111
|
else
|
|
109
|
-
@example_group_class.
|
|
112
|
+
@example_group_class.run_around_each_hooks(self, Example.procsy(metadata, &block)).call
|
|
110
113
|
end
|
|
111
114
|
end
|
|
112
115
|
|
|
@@ -142,11 +145,11 @@ module RSpec
|
|
|
142
145
|
|
|
143
146
|
def run_before_each
|
|
144
147
|
@example_group_instance.setup_mocks_for_rspec if @example_group_instance.respond_to?(:setup_mocks_for_rspec)
|
|
145
|
-
@example_group_class.
|
|
148
|
+
@example_group_class.run_before_each_hooks(self)
|
|
146
149
|
end
|
|
147
150
|
|
|
148
151
|
def run_after_each
|
|
149
|
-
@example_group_class.
|
|
152
|
+
@example_group_class.run_after_each_hooks(self)
|
|
150
153
|
@example_group_instance.verify_mocks_for_rspec if @example_group_instance.respond_to?(:verify_mocks_for_rspec)
|
|
151
154
|
ensure
|
|
152
155
|
@example_group_instance.teardown_mocks_for_rspec if @example_group_instance.respond_to?(:teardown_mocks_for_rspec)
|
|
@@ -60,16 +60,20 @@ module RSpec
|
|
|
60
60
|
|
|
61
61
|
alias_example_to :it
|
|
62
62
|
alias_example_to :specify
|
|
63
|
-
|
|
64
|
-
alias_example_to :
|
|
65
|
-
alias_example_to :
|
|
66
|
-
alias_example_to :xit,
|
|
63
|
+
|
|
64
|
+
alias_example_to :pending, :pending => true
|
|
65
|
+
alias_example_to :xexample, :pending => true
|
|
66
|
+
alias_example_to :xit, :pending => true
|
|
67
|
+
alias_example_to :xspecify, :pending => true
|
|
68
|
+
|
|
69
|
+
alias_example_to :focused, :focused => true, :focus => true
|
|
70
|
+
alias_example_to :focus, :focused => true, :focus => true
|
|
67
71
|
|
|
68
72
|
def self.define_nested_shared_group_method(new_name, report_label=nil)
|
|
69
73
|
module_eval(<<-END_RUBY, __FILE__, __LINE__)
|
|
70
74
|
def self.#{new_name}(name, *args, &customization_block)
|
|
71
|
-
shared_block =
|
|
72
|
-
raise "Could not find shared
|
|
75
|
+
shared_block = find_shared("examples", name)
|
|
76
|
+
raise "Could not find shared examples \#{name.inspect}" unless shared_block
|
|
73
77
|
|
|
74
78
|
group = describe("#{report_label || "it should behave like"} \#{name}") do
|
|
75
79
|
module_eval_with_args(*args, &shared_block)
|
|
@@ -90,11 +94,19 @@ module RSpec
|
|
|
90
94
|
alias_it_should_behave_like_to :it_behaves_like, "behaves like"
|
|
91
95
|
|
|
92
96
|
def self.include_context(name)
|
|
93
|
-
module_eval(&
|
|
97
|
+
module_eval(&find_shared("context", name))
|
|
94
98
|
end
|
|
95
99
|
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
def self.include_examples(name)
|
|
101
|
+
module_eval(&find_shared("examples", name))
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def self.find_shared(label, name)
|
|
105
|
+
if world.shared_example_groups.has_key?(name)
|
|
106
|
+
world.shared_example_groups[name]
|
|
107
|
+
else
|
|
108
|
+
raise ArgumentError, "Could not find shared #{label} #{name.inspect}"
|
|
109
|
+
end
|
|
98
110
|
end
|
|
99
111
|
|
|
100
112
|
def self.examples
|
|
@@ -200,7 +212,7 @@ module RSpec
|
|
|
200
212
|
ivars.each { |ivar, val| example_group_instance.instance_variable_set(ivar, val) }
|
|
201
213
|
end
|
|
202
214
|
|
|
203
|
-
def self.
|
|
215
|
+
def self.run_before_all_hooks(example_group_instance)
|
|
204
216
|
return if descendant_filtered_examples.empty?
|
|
205
217
|
assign_before_all_ivars(superclass.before_all_ivars, example_group_instance)
|
|
206
218
|
world.run_hook_filtered(:before, :all, self, example_group_instance)
|
|
@@ -208,7 +220,7 @@ module RSpec
|
|
|
208
220
|
store_before_all_ivars(example_group_instance)
|
|
209
221
|
end
|
|
210
222
|
|
|
211
|
-
def self.
|
|
223
|
+
def self.run_around_each_hooks(example, initial_procsy)
|
|
212
224
|
example.around_hooks.reverse.inject(initial_procsy) do |procsy, around_hook|
|
|
213
225
|
Example.procsy(procsy.metadata) do
|
|
214
226
|
example.example_group_instance.instance_eval_with_args(procsy, &around_hook)
|
|
@@ -216,17 +228,17 @@ module RSpec
|
|
|
216
228
|
end
|
|
217
229
|
end
|
|
218
230
|
|
|
219
|
-
def self.
|
|
231
|
+
def self.run_before_each_hooks(example)
|
|
220
232
|
world.run_hook_filtered(:before, :each, self, example.example_group_instance, example)
|
|
221
233
|
ancestors.reverse.each { |ancestor| ancestor.run_hook(:before, :each, example.example_group_instance) }
|
|
222
234
|
end
|
|
223
235
|
|
|
224
|
-
def self.
|
|
236
|
+
def self.run_after_each_hooks(example)
|
|
225
237
|
ancestors.each { |ancestor| ancestor.run_hook(:after, :each, example.example_group_instance) }
|
|
226
238
|
world.run_hook_filtered(:after, :each, self, example.example_group_instance, example)
|
|
227
239
|
end
|
|
228
240
|
|
|
229
|
-
def self.
|
|
241
|
+
def self.run_after_all_hooks(example_group_instance)
|
|
230
242
|
return if descendant_filtered_examples.empty?
|
|
231
243
|
assign_before_all_ivars(before_all_ivars, example_group_instance)
|
|
232
244
|
|
|
@@ -258,14 +270,14 @@ An error occurred in an after(:all) hook.
|
|
|
258
270
|
reporter.example_group_started(self)
|
|
259
271
|
|
|
260
272
|
begin
|
|
261
|
-
|
|
273
|
+
run_before_all_hooks(new)
|
|
262
274
|
result_for_this_group = run_examples(reporter)
|
|
263
275
|
results_for_descendants = children.map {|child| child.run(reporter)}.all?
|
|
264
276
|
result_for_this_group && results_for_descendants
|
|
265
277
|
rescue Exception => ex
|
|
266
278
|
fail_filtered_examples(ex, reporter)
|
|
267
279
|
ensure
|
|
268
|
-
|
|
280
|
+
run_after_all_hooks(new)
|
|
269
281
|
before_all_ivars.clear
|
|
270
282
|
reporter.example_group_finished(self)
|
|
271
283
|
end
|
|
@@ -297,8 +309,12 @@ An error occurred in an after(:all) hook.
|
|
|
297
309
|
end.all?
|
|
298
310
|
end
|
|
299
311
|
|
|
300
|
-
def self.
|
|
301
|
-
metadata.
|
|
312
|
+
def self.any_apply?(filters)
|
|
313
|
+
metadata.any_apply?(filters)
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def self.all_apply?(filters)
|
|
317
|
+
metadata.all_apply?(filters)
|
|
302
318
|
end
|
|
303
319
|
|
|
304
320
|
def self.declaration_line_numbers
|
|
@@ -12,6 +12,13 @@ module RSpec
|
|
|
12
12
|
attr_reader :example_count, :pending_count, :failure_count
|
|
13
13
|
attr_reader :failed_examples, :pending_examples
|
|
14
14
|
|
|
15
|
+
def self.relative_path(line)
|
|
16
|
+
line = line.sub(File.expand_path("."), ".")
|
|
17
|
+
line = line.sub(/\A([^:]+:\d+)$/, '\\1')
|
|
18
|
+
return nil if line == '-e:1'
|
|
19
|
+
line
|
|
20
|
+
end
|
|
21
|
+
|
|
15
22
|
def initialize(output)
|
|
16
23
|
@output = output || StringIO.new
|
|
17
24
|
@example_count = @pending_count = @failure_count = 0
|
|
@@ -113,10 +120,7 @@ module RSpec
|
|
|
113
120
|
|
|
114
121
|
def backtrace_line(line)
|
|
115
122
|
return nil if configuration.cleaned_from_backtrace?(line)
|
|
116
|
-
|
|
117
|
-
line = line.sub(/\A([^:]+:\d+)$/, '\\1')
|
|
118
|
-
return nil if line == '-e:1'
|
|
119
|
-
line
|
|
123
|
+
self.class.relative_path(line)
|
|
120
124
|
end
|
|
121
125
|
|
|
122
126
|
def read_failed_line(exception, example)
|