rspec-core 2.13.1 → 2.14.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +80 -0
- data/exe/autospec +1 -1
- data/features/README.md +2 -2
- data/features/command_line/format_option.feature +8 -14
- data/features/command_line/line_number_appended_to_path.feature +4 -4
- data/features/command_line/line_number_option.feature +1 -1
- data/features/command_line/rake_task.feature +2 -2
- data/features/command_line/require_option.feature +43 -0
- data/features/command_line/ruby.feature +2 -2
- data/features/command_line/warnings_option.feature +27 -0
- data/features/configuration/backtrace_clean_patterns.feature +2 -2
- data/features/configuration/deprecation_stream.feature +58 -0
- data/features/configuration/pattern.feature +8 -0
- data/features/configuration/profile.feature +59 -2
- data/features/configuration/read_options_from_file.feature +8 -5
- data/features/configuration/run_all_when_everything_filtered.feature +20 -4
- data/features/example_groups/basic_structure.feature +1 -1
- data/features/example_groups/shared_context.feature +1 -1
- data/features/example_groups/shared_examples.feature +72 -0
- data/features/filtering/exclusion_filters.feature +10 -10
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/hooks/before_and_after_hooks.feature +19 -19
- data/features/mock_framework_integration/use_any_framework.feature +6 -6
- data/features/mock_framework_integration/use_flexmock.feature +3 -3
- data/features/mock_framework_integration/use_mocha.feature +3 -3
- data/features/mock_framework_integration/use_rr.feature +3 -3
- data/features/mock_framework_integration/use_rspec.feature +3 -3
- data/features/subject/implicit_subject.feature +1 -1
- data/lib/rspec/core.rb +20 -3
- data/lib/rspec/core/backtrace_cleaner.rb +46 -0
- data/lib/rspec/core/backward_compatibility.rb +3 -13
- data/lib/rspec/core/configuration.rb +136 -49
- data/lib/rspec/core/configuration_options.rb +19 -8
- data/lib/rspec/core/deprecation.rb +18 -30
- data/lib/rspec/core/example.rb +3 -3
- data/lib/rspec/core/example_group.rb +4 -3
- data/lib/rspec/core/extensions/kernel.rb +1 -1
- data/lib/rspec/core/filter_manager.rb +1 -1
- data/lib/rspec/core/formatters.rb +1 -1
- data/lib/rspec/core/formatters/base_formatter.rb +10 -1
- data/lib/rspec/core/formatters/base_text_formatter.rb +47 -10
- data/lib/rspec/core/formatters/deprecation_formatter.rb +35 -0
- data/lib/rspec/core/formatters/helpers.rb +12 -5
- data/lib/rspec/core/formatters/html_formatter.rb +7 -6
- data/lib/rspec/core/formatters/html_printer.rb +13 -12
- data/lib/rspec/core/formatters/json_formatter.rb +1 -2
- data/lib/rspec/core/formatters/text_mate_formatter.rb +1 -1
- data/lib/rspec/core/hooks.rb +9 -0
- data/lib/rspec/core/memoized_helpers.rb +19 -8
- data/lib/rspec/core/metadata.rb +3 -1
- data/lib/rspec/core/mocking/with_flexmock.rb +1 -1
- data/lib/rspec/core/mocking/with_rr.rb +1 -1
- data/lib/rspec/core/option_parser.rb +6 -2
- data/lib/rspec/core/pending.rb +1 -0
- data/lib/rspec/core/rake_task.rb +11 -19
- data/lib/rspec/core/reporter.rb +33 -4
- data/lib/rspec/core/shared_example_group.rb +56 -16
- data/lib/rspec/core/shared_example_group/collection.rb +42 -0
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +2 -3
- data/spec/autotest/rspec_spec.rb +2 -2
- data/spec/rspec/core/backtrace_cleaner_spec.rb +68 -0
- data/spec/rspec/core/configuration_options_spec.rb +15 -4
- data/spec/rspec/core/configuration_spec.rb +202 -19
- data/spec/rspec/core/deprecation_spec.rb +41 -0
- data/spec/rspec/core/deprecations_spec.rb +10 -12
- data/spec/rspec/core/drb_command_line_spec.rb +1 -1
- data/spec/rspec/core/example_group_spec.rb +37 -36
- data/spec/rspec/core/example_spec.rb +25 -4
- data/spec/rspec/core/filter_manager_spec.rb +6 -6
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +101 -36
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +78 -0
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -2
- data/spec/rspec/core/formatters/helpers_spec.rb +23 -7
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +20 -14
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +69 -169
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +28 -23
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +42 -33
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +17 -23
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +57 -157
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +42 -33
- data/spec/rspec/core/formatters/html_formatted-2.0.0.html +42 -33
- data/spec/rspec/core/formatters/html_formatter_spec.rb +1 -0
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +3 -3
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +11 -14
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +103 -203
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +30 -25
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +42 -33
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-jruby.html +20 -14
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +103 -203
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +42 -33
- data/spec/rspec/core/formatters/text_mate_formatted-2.0.0.html +42 -33
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +1 -0
- data/spec/rspec/core/memoized_helpers_spec.rb +28 -0
- data/spec/rspec/core/metadata_spec.rb +8 -3
- data/spec/rspec/core/option_parser_spec.rb +8 -0
- data/spec/rspec/core/project_initializer_spec.rb +2 -2
- data/spec/rspec/core/rake_task_spec.rb +8 -8
- data/spec/rspec/core/reporter_spec.rb +26 -6
- data/spec/rspec/core/resources/formatter_specs.rb +3 -3
- data/spec/rspec/core/shared_context_spec.rb +20 -0
- data/spec/rspec/core/shared_example_group/collection_spec.rb +70 -0
- data/spec/rspec/core/shared_example_group_spec.rb +4 -4
- data/spec/rspec/core/world_spec.rb +1 -3
- data/spec/rspec/core_spec.rb +20 -0
- data/spec/spec_helper.rb +29 -29
- data/spec/support/helper_methods.rb +9 -1
- data/spec/support/isolate_load_path_mutation.rb +6 -0
- data/spec/support/sandboxed_mock_space.rb +100 -0
- metadata +28 -13
- data/features/filtering/run_all_when_everything_filtered.feature +0 -46
- data/lib/rspec/core/load_path.rb +0 -3
@@ -0,0 +1,42 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Core
|
3
|
+
module SharedExampleGroup
|
4
|
+
class Collection
|
5
|
+
|
6
|
+
def initialize(sources, examples)
|
7
|
+
@sources, @examples = sources, examples
|
8
|
+
end
|
9
|
+
|
10
|
+
def [](key)
|
11
|
+
fetch_examples(key) || warn_deprecation_and_fetch_anyway(key)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def fetch_examples(key)
|
17
|
+
@examples[source_for key][key]
|
18
|
+
end
|
19
|
+
|
20
|
+
def source_for(key)
|
21
|
+
@sources.reverse.find { |source| @examples[source].has_key? key }
|
22
|
+
end
|
23
|
+
|
24
|
+
def fetch_anyway(key)
|
25
|
+
@examples.values.inject({}, &:merge)[key]
|
26
|
+
end
|
27
|
+
|
28
|
+
def warn_deprecation_and_fetch_anyway(key)
|
29
|
+
if (example = fetch_anyway key)
|
30
|
+
RSpec.warn_deprecation <<-WARNING.gsub(/^ /, '')
|
31
|
+
Accessing shared_examples defined across contexts is deprecated.
|
32
|
+
Please declare shared_examples within a shared context, or at the top level.
|
33
|
+
This message was generated at: #{caller(0)[8]}
|
34
|
+
WARNING
|
35
|
+
example
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/rspec/core/version.rb
CHANGED
data/lib/rspec/core/world.rb
CHANGED
@@ -4,13 +4,12 @@ module RSpec
|
|
4
4
|
|
5
5
|
include RSpec::Core::Hooks
|
6
6
|
|
7
|
-
attr_reader :example_groups, :
|
7
|
+
attr_reader :example_groups, :filtered_examples
|
8
8
|
attr_accessor :wants_to_quit
|
9
9
|
|
10
10
|
def initialize(configuration=RSpec.configuration)
|
11
11
|
@configuration = configuration
|
12
12
|
@example_groups = [].extend(Extensions::Ordered::ExampleGroups)
|
13
|
-
@shared_example_groups = {}
|
14
13
|
@filtered_examples = Hash.new { |hash,group|
|
15
14
|
hash[group] = begin
|
16
15
|
examples = group.examples.dup
|
@@ -23,7 +22,7 @@ module RSpec
|
|
23
22
|
|
24
23
|
def reset
|
25
24
|
example_groups.clear
|
26
|
-
|
25
|
+
SharedExampleGroup::Registry.clear
|
27
26
|
end
|
28
27
|
|
29
28
|
def filter_manager
|
data/spec/autotest/rspec_spec.rb
CHANGED
@@ -40,8 +40,8 @@ describe Autotest::Rspec2 do
|
|
40
40
|
expect(actual_command).to match(expected_command)
|
41
41
|
|
42
42
|
actual_command =~ expected_command
|
43
|
-
expect($1).to match
|
44
|
-
expect($1).to match
|
43
|
+
expect($1).to match(/#{File.expand_path('file_one')}/)
|
44
|
+
expect($1).to match(/#{File.expand_path('file_two')}/)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "returns a blank command for no files" do
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module RSpec::Core
|
4
|
+
describe BacktraceCleaner do
|
5
|
+
context "with no patterns" do
|
6
|
+
it "keeps all lines" do
|
7
|
+
lines = ["/tmp/a_file", "some_random_text", "hello\330\271!"]
|
8
|
+
cleaner = BacktraceCleaner.new([], [])
|
9
|
+
expect(lines.all? {|line| cleaner.exclude? line}).to be_false
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'is considered a full backtrace' do
|
13
|
+
expect(BacktraceCleaner.new([], []).full_backtrace?).to be_true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with an exclusion pattern but no inclusion patterns" do
|
18
|
+
it "excludes lines that match the exclusion pattern" do
|
19
|
+
cleaner = BacktraceCleaner.new([], [/remove/])
|
20
|
+
expect(cleaner.exclude? "remove me").to be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "keeps lines that do not match the exclusion pattern" do
|
24
|
+
cleaner = BacktraceCleaner.new([], [/remove/])
|
25
|
+
expect(cleaner.exclude? "apple").to be_false
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'is considered a partial backtrace' do
|
29
|
+
expect(BacktraceCleaner.new([], [/remove/]).full_backtrace?).to be_false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with an exclusion pattern and an inclusion pattern" do
|
34
|
+
it "excludes lines that match the exclusion pattern but not the inclusion pattern" do
|
35
|
+
cleaner = BacktraceCleaner.new([/keep/], [/discard/])
|
36
|
+
expect(cleaner.exclude? "discard").to be_true
|
37
|
+
end
|
38
|
+
|
39
|
+
it "keeps lines that match the inclusion pattern and the exclusion pattern" do
|
40
|
+
cleaner = BacktraceCleaner.new([/hi/], [/.*/])
|
41
|
+
expect(cleaner.exclude? "hi").to be_false
|
42
|
+
end
|
43
|
+
|
44
|
+
it "keeps lines that match neither pattern" do
|
45
|
+
cleaner = BacktraceCleaner.new([/hi/], [/delete/])
|
46
|
+
expect(cleaner.exclude? "fish").to be_false
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'is considered a partial backtrace' do
|
50
|
+
expect(BacktraceCleaner.new([], [/remove/]).full_backtrace?).to be_false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with an exclusion pattern that matches the current working directory" do
|
55
|
+
it "defaults to having one inclusion pattern, the current working directory" do
|
56
|
+
cleaner = BacktraceCleaner.new(nil, [/.*/])
|
57
|
+
expect(Dir.getwd =~ cleaner.inclusion_patterns.first).to be_true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "with an exclusion pattern that does not match the current working directory" do
|
62
|
+
it "defaults to having no exclusion patterns" do
|
63
|
+
cleaner = BacktraceCleaner.new(nil, [/i_wont_match_a_directory/])
|
64
|
+
expect(cleaner.inclusion_patterns.length).to be_zero
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -25,14 +25,14 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
|
|
25
25
|
opts = config_options_object(*%w[--require a/path -I a/lib])
|
26
26
|
config = double("config").as_null_object
|
27
27
|
config.should_receive(:libs=).ordered
|
28
|
-
config.should_receive(:
|
28
|
+
config.should_receive(:setup_load_path_and_require).ordered
|
29
29
|
opts.configure(config)
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "sets up load path and requires before formatter" do
|
33
33
|
opts = config_options_object(*%w[--require a/path -f a/formatter])
|
34
34
|
config = double("config").as_null_object
|
35
|
-
config.should_receive(:
|
35
|
+
config.should_receive(:setup_load_path_and_require).ordered
|
36
36
|
config.should_receive(:add_formatter).ordered
|
37
37
|
opts.configure(config)
|
38
38
|
end
|
@@ -105,7 +105,8 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
|
|
105
105
|
with_env_vars 'SPEC_OPTS' => "--require file_from_env" do
|
106
106
|
opts = config_options_object(*%w[--require file_from_opts])
|
107
107
|
config = RSpec::Core::Configuration.new
|
108
|
-
config.should_receive(:
|
108
|
+
config.should_receive(:require).with("file_from_opts")
|
109
|
+
config.should_receive(:require).with("file_from_env")
|
109
110
|
opts.configure(config)
|
110
111
|
end
|
111
112
|
end
|
@@ -378,6 +379,16 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
|
|
378
379
|
expect(parse_options[:formatters]).to eq([['local']])
|
379
380
|
end
|
380
381
|
|
382
|
+
it "parses options file correctly if erb code has trimming options" do
|
383
|
+
File.open("./.rspec", "w") do |f|
|
384
|
+
f << "<% if true -%>\n"
|
385
|
+
f << "--format local\n"
|
386
|
+
f << "<%- end %>\n"
|
387
|
+
end
|
388
|
+
|
389
|
+
expect(parse_options[:formatters]).to eq([['local']])
|
390
|
+
end
|
391
|
+
|
381
392
|
context "with custom options file" do
|
382
393
|
it "ignores project and global options files" do
|
383
394
|
File.open("./.rspec", "w") {|f| f << "--format project"}
|
@@ -16,8 +16,59 @@ module RSpec::Core
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
19
|
+
describe '#deprecation_stream' do
|
20
|
+
it 'defaults to standard error' do
|
21
|
+
expect(config.deprecation_stream).to eq $stderr
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'is configurable' do
|
25
|
+
io = double 'deprecation io'
|
26
|
+
config.deprecation_stream = io
|
27
|
+
expect(config.deprecation_stream).to eq io
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#setup_load_path_and_require" do
|
32
|
+
include_context "isolate load path mutation"
|
33
|
+
|
34
|
+
def absolute_path_to(dir)
|
35
|
+
File.expand_path("../../../../#{dir}", __FILE__)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'adds `lib` to the load path' do
|
39
|
+
lib_dir = absolute_path_to("lib")
|
40
|
+
$LOAD_PATH.delete(lib_dir)
|
41
|
+
|
42
|
+
expect($LOAD_PATH).not_to include(lib_dir)
|
43
|
+
config.setup_load_path_and_require []
|
44
|
+
expect($LOAD_PATH).to include(lib_dir)
|
45
|
+
end
|
20
46
|
|
47
|
+
it 'adds the configured `default_path` to the load path' do
|
48
|
+
config.default_path = 'features'
|
49
|
+
foo_dir = absolute_path_to("features")
|
50
|
+
|
51
|
+
expect($LOAD_PATH).not_to include(foo_dir)
|
52
|
+
config.setup_load_path_and_require []
|
53
|
+
expect($LOAD_PATH).to include(foo_dir)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'stores the required files' do
|
57
|
+
config.should_receive(:require).with('a/path')
|
58
|
+
config.setup_load_path_and_require ['a/path']
|
59
|
+
expect(config.requires).to eq ['a/path']
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when `default_path` refers to a file rather than a directory" do
|
63
|
+
it 'does not add it to the load path' do
|
64
|
+
config.default_path = 'Rakefile'
|
65
|
+
config.setup_load_path_and_require []
|
66
|
+
expect($LOAD_PATH).not_to include(match(/Rakefile/))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#load_spec_files" do
|
21
72
|
it "loads files using load" do
|
22
73
|
config.files_to_run = ["foo.bar", "blah_spec.rb"]
|
23
74
|
config.should_receive(:load).twice
|
@@ -354,7 +405,7 @@ module RSpec::Core
|
|
354
405
|
%w[ a/2.rb a/1.rb a/3.rb ],
|
355
406
|
%w[ a/3.rb a/2.rb a/1.rb ]
|
356
407
|
].map do |files|
|
357
|
-
Dir.should_receive(:[]).with(
|
408
|
+
Dir.should_receive(:[]).with(/^\{?a/) { files }
|
358
409
|
yield
|
359
410
|
config.files_to_run
|
360
411
|
end
|
@@ -435,6 +486,14 @@ module RSpec::Core
|
|
435
486
|
expect(config.files_to_run).to include("#{dir}/a_foo.rb")
|
436
487
|
expect(config.files_to_run).to include("#{dir}/a_bar.rb")
|
437
488
|
end
|
489
|
+
|
490
|
+
it "supports curly braces glob syntax" do
|
491
|
+
config.send(setter, "**/*_{foo,bar}.rb")
|
492
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
493
|
+
config.files_or_directories_to_run = dir
|
494
|
+
expect(config.files_to_run).to include("#{dir}/a_foo.rb")
|
495
|
+
expect(config.files_to_run).to include("#{dir}/a_bar.rb")
|
496
|
+
end
|
438
497
|
end
|
439
498
|
end
|
440
499
|
end
|
@@ -446,16 +505,26 @@ module RSpec::Core
|
|
446
505
|
end
|
447
506
|
end
|
448
507
|
|
449
|
-
context "with full_description" do
|
508
|
+
context "with full_description set" do
|
450
509
|
it "overrides filters" do
|
451
510
|
config.filter_run :focused => true
|
452
511
|
config.full_description = "foo"
|
453
512
|
expect(config.filter).not_to have_key(:focused)
|
454
513
|
end
|
514
|
+
|
515
|
+
it 'is possible to access the full description regular expression' do
|
516
|
+
config.full_description = "foo"
|
517
|
+
expect(config.full_description).to eq(/foo/)
|
518
|
+
end
|
455
519
|
end
|
456
520
|
|
457
|
-
context "
|
521
|
+
context "without full_description having been set" do
|
522
|
+
it 'returns nil from #full_description' do
|
523
|
+
expect(config.full_description).to eq nil
|
524
|
+
end
|
525
|
+
end
|
458
526
|
|
527
|
+
context "with line number" do
|
459
528
|
it "assigns the file and line number as a location filter" do
|
460
529
|
config.files_or_directories_to_run = "path/to/a_spec.rb:37"
|
461
530
|
expect(config.filter).to eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37]}})
|
@@ -490,6 +559,11 @@ module RSpec::Core
|
|
490
559
|
expect(config.filter).to eq({:full_description => Regexp.union(/foo/, /bar/)})
|
491
560
|
end
|
492
561
|
|
562
|
+
it 'is possible to access the full description regular expression' do
|
563
|
+
config.full_description = "foo","bar"
|
564
|
+
expect(config.full_description).to eq Regexp.union(/foo/,/bar/)
|
565
|
+
end
|
566
|
+
|
493
567
|
describe "#default_path" do
|
494
568
|
it 'defaults to "spec"' do
|
495
569
|
expect(config.default_path).to eq('spec')
|
@@ -907,18 +981,29 @@ module RSpec::Core
|
|
907
981
|
end
|
908
982
|
end
|
909
983
|
|
984
|
+
describe "line_numbers" do
|
985
|
+
it "returns the line numbers from the filter" do
|
986
|
+
config.line_numbers = ['42']
|
987
|
+
expect(config.line_numbers).to eq [42]
|
988
|
+
end
|
989
|
+
|
990
|
+
it "defaults to empty" do
|
991
|
+
expect(config.line_numbers).to eq []
|
992
|
+
end
|
993
|
+
end
|
994
|
+
|
910
995
|
describe "#full_backtrace=" do
|
911
996
|
context "given true" do
|
912
|
-
it "clears the backtrace
|
997
|
+
it "clears the backtrace exclusion patterns" do
|
913
998
|
config.full_backtrace = true
|
914
|
-
expect(config.
|
999
|
+
expect(config.backtrace_exclusion_patterns).to eq([])
|
915
1000
|
end
|
916
1001
|
end
|
917
1002
|
|
918
1003
|
context "given false" do
|
919
1004
|
it "restores backtrace clean patterns" do
|
920
1005
|
config.full_backtrace = false
|
921
|
-
expect(config.
|
1006
|
+
expect(config.backtrace_exclusion_patterns).to eq(RSpec::Core::BacktraceCleaner::DEFAULT_EXCLUSION_PATTERNS)
|
922
1007
|
end
|
923
1008
|
end
|
924
1009
|
|
@@ -927,29 +1012,69 @@ module RSpec::Core
|
|
927
1012
|
config_2 = Configuration.new
|
928
1013
|
|
929
1014
|
config_1.full_backtrace = true
|
930
|
-
expect(config_2.
|
1015
|
+
expect(config_2.backtrace_exclusion_patterns).not_to be_empty
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
describe "#backtrace_clean_patterns=" do
|
1020
|
+
it "actually receives the new filter values" do
|
1021
|
+
RSpec.stub(:deprecate)
|
1022
|
+
config = Configuration.new
|
1023
|
+
config.backtrace_clean_patterns = [/.*/]
|
1024
|
+
expect(config.backtrace_cleaner.exclude? "this").to be_true
|
931
1025
|
end
|
932
1026
|
end
|
933
1027
|
|
934
|
-
describe
|
1028
|
+
describe 'full_backtrace' do
|
1029
|
+
it 'returns true when backtrace patterns is empty' do
|
1030
|
+
config.backtrace_exclusion_patterns = []
|
1031
|
+
expect(config.full_backtrace?).to eq true
|
1032
|
+
end
|
1033
|
+
|
1034
|
+
it 'returns false when backtrace patterns isnt empty' do
|
1035
|
+
config.backtrace_exclusion_patterns = [:lib]
|
1036
|
+
expect(config.full_backtrace?).to eq false
|
1037
|
+
end
|
1038
|
+
end
|
1039
|
+
|
1040
|
+
describe "#backtrace_clean_patterns" do
|
1041
|
+
before { allow(RSpec).to receive(:deprecate) }
|
1042
|
+
it "is deprecated" do
|
1043
|
+
RSpec.should_receive(:deprecate)
|
1044
|
+
config = Configuration.new
|
1045
|
+
config.backtrace_clean_patterns
|
1046
|
+
end
|
1047
|
+
|
1048
|
+
it "can be appended to" do
|
1049
|
+
config = Configuration.new
|
1050
|
+
config.backtrace_clean_patterns << /.*/
|
1051
|
+
expect(config.backtrace_cleaner.exclude? "this").to be_true
|
1052
|
+
end
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
describe ".backtrace_cleaner#exclude? defaults" do
|
935
1056
|
it "returns true for rspec files" do
|
936
|
-
expect(config.
|
1057
|
+
expect(config.backtrace_cleaner.exclude?("lib/rspec/core.rb")).to be_true
|
937
1058
|
end
|
938
1059
|
|
939
1060
|
it "returns true for spec_helper" do
|
940
|
-
expect(config.
|
1061
|
+
expect(config.backtrace_cleaner.exclude?("spec/spec_helper.rb")).to be_true
|
941
1062
|
end
|
942
1063
|
|
943
1064
|
it "returns true for java files (for JRuby)" do
|
944
|
-
expect(config.
|
1065
|
+
expect(config.backtrace_cleaner.exclude?("org/jruby/RubyArray.java:2336")).to be_true
|
945
1066
|
end
|
946
1067
|
|
947
1068
|
it "returns true for files within installed gems" do
|
948
|
-
expect(config.
|
1069
|
+
expect(config.backtrace_cleaner.exclude?('ruby-1.8.7-p334/gems/mygem-2.3.0/lib/mygem.rb')).to be_true
|
949
1070
|
end
|
950
1071
|
|
951
1072
|
it "returns false for files in projects containing 'gems' in the name" do
|
952
|
-
expect(config.
|
1073
|
+
expect(config.backtrace_cleaner.exclude?('code/my-gems-plugin/lib/plugin.rb')).to be_false
|
1074
|
+
end
|
1075
|
+
|
1076
|
+
it "returns false for something in the current working directory" do
|
1077
|
+
expect(config.backtrace_cleaner.exclude?("#{Dir.getwd}/arbitrary")).to be_false
|
953
1078
|
end
|
954
1079
|
end
|
955
1080
|
|
@@ -961,6 +1086,7 @@ module RSpec::Core
|
|
961
1086
|
else
|
962
1087
|
@orig_debugger = nil
|
963
1088
|
end
|
1089
|
+
config.stub(:require)
|
964
1090
|
Object.const_set("Debugger", debugger)
|
965
1091
|
end
|
966
1092
|
|
@@ -977,10 +1103,14 @@ module RSpec::Core
|
|
977
1103
|
end
|
978
1104
|
|
979
1105
|
it "starts the debugger" do
|
980
|
-
config.stub(:require)
|
981
1106
|
debugger.should_receive(:start)
|
982
1107
|
config.debug = true
|
983
1108
|
end
|
1109
|
+
|
1110
|
+
it 'sets the reader to true' do
|
1111
|
+
config.debug = true
|
1112
|
+
expect(config.debug?).to eq true
|
1113
|
+
end
|
984
1114
|
end
|
985
1115
|
|
986
1116
|
describe "#debug=false" do
|
@@ -988,6 +1118,11 @@ module RSpec::Core
|
|
988
1118
|
config.should_not_receive(:require).with('ruby-debug')
|
989
1119
|
config.debug = false
|
990
1120
|
end
|
1121
|
+
|
1122
|
+
it 'sets the reader to false' do
|
1123
|
+
config.debug = false
|
1124
|
+
expect(config.debug?).to eq false
|
1125
|
+
end
|
991
1126
|
end
|
992
1127
|
|
993
1128
|
describe "#output=" do
|
@@ -999,16 +1134,36 @@ module RSpec::Core
|
|
999
1134
|
end
|
1000
1135
|
|
1001
1136
|
describe "#libs=" do
|
1137
|
+
include_context "isolate load path mutation"
|
1138
|
+
|
1002
1139
|
it "adds directories to the LOAD_PATH" do
|
1003
1140
|
$LOAD_PATH.should_receive(:unshift).with("a/dir")
|
1004
1141
|
config.libs = ["a/dir"]
|
1005
1142
|
end
|
1006
1143
|
end
|
1007
1144
|
|
1145
|
+
describe "libs" do
|
1146
|
+
include_context "isolate load path mutation"
|
1147
|
+
|
1148
|
+
it 'records paths added to the load path' do
|
1149
|
+
config.libs = ["a/dir"]
|
1150
|
+
expect(config.libs).to eq ["a/dir"]
|
1151
|
+
end
|
1152
|
+
end
|
1153
|
+
|
1008
1154
|
describe "#requires=" do
|
1009
|
-
|
1155
|
+
before { RSpec.should_receive :deprecate }
|
1156
|
+
|
1157
|
+
it "requires the configured files" do
|
1158
|
+
config.should_receive(:require).with('foo').ordered
|
1159
|
+
config.should_receive(:require).with('bar').ordered
|
1160
|
+
config.requires = ['foo', 'bar']
|
1161
|
+
end
|
1162
|
+
|
1163
|
+
it "stores require paths" do
|
1010
1164
|
config.should_receive(:require).with("a/path")
|
1011
1165
|
config.requires = ["a/path"]
|
1166
|
+
expect(config.requires).to eq ['a/path']
|
1012
1167
|
end
|
1013
1168
|
end
|
1014
1169
|
|
@@ -1065,7 +1220,7 @@ module RSpec::Core
|
|
1065
1220
|
|
1066
1221
|
context "with :alias => " do
|
1067
1222
|
it "is deprecated" do
|
1068
|
-
RSpec::should_receive(:
|
1223
|
+
RSpec::should_receive(:deprecate).with(/:alias option/, :replacement => ":alias_with")
|
1069
1224
|
config.add_setting :custom_option
|
1070
1225
|
config.add_setting :another_custom_option, :alias => :custom_option
|
1071
1226
|
end
|
@@ -1317,7 +1472,7 @@ module RSpec::Core
|
|
1317
1472
|
it 'sets a block that determines the ordering of a collection extended with Extensions::Ordered::Examples' do
|
1318
1473
|
examples = [1, 2, 3, 4]
|
1319
1474
|
examples.extend Extensions::Ordered::Examples
|
1320
|
-
config.order_examples { |
|
1475
|
+
config.order_examples { |examples_to_order| examples_to_order.reverse }
|
1321
1476
|
expect(examples.ordered).to eq([4, 3, 2, 1])
|
1322
1477
|
end
|
1323
1478
|
|
@@ -1339,7 +1494,7 @@ module RSpec::Core
|
|
1339
1494
|
it 'sets a block that determines the ordering of a collection extended with Extensions::Ordered::ExampleGroups' do
|
1340
1495
|
groups = [1, 2, 3, 4]
|
1341
1496
|
groups.extend Extensions::Ordered::ExampleGroups
|
1342
|
-
config.order_groups { |
|
1497
|
+
config.order_groups { |groups_to_order| groups_to_order.reverse }
|
1343
1498
|
expect(groups.ordered).to eq([4, 3, 2, 1])
|
1344
1499
|
end
|
1345
1500
|
|
@@ -1372,5 +1527,33 @@ module RSpec::Core
|
|
1372
1527
|
expect(groups.ordered).to eq([4, 3, 2, 1])
|
1373
1528
|
end
|
1374
1529
|
end
|
1530
|
+
|
1531
|
+
describe '#warnings' do
|
1532
|
+
around do |example|
|
1533
|
+
@_original_setting = $VERBOSE
|
1534
|
+
example.run
|
1535
|
+
$VERBOSE = @_original_setting
|
1536
|
+
end
|
1537
|
+
|
1538
|
+
it "sets verbose to true when true" do
|
1539
|
+
config.warnings = true
|
1540
|
+
expect($VERBOSE).to eq true
|
1541
|
+
end
|
1542
|
+
|
1543
|
+
it "sets verbose to false when true" do
|
1544
|
+
config.warnings = false
|
1545
|
+
expect($VERBOSE).to eq false
|
1546
|
+
end
|
1547
|
+
|
1548
|
+
it 'returns the verbosity setting' do
|
1549
|
+
expect(config.warnings).to eq $VERBOSE
|
1550
|
+
end
|
1551
|
+
|
1552
|
+
it 'is loaded from config by #force' do
|
1553
|
+
config.force :warnings => true
|
1554
|
+
expect($VERBOSE).to eq true
|
1555
|
+
end
|
1556
|
+
end
|
1557
|
+
|
1375
1558
|
end
|
1376
1559
|
end
|