Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 9909d34

Browse files
committed
Run expectation outside of $SAFE 1+ environment
... because the matcher may be autoloaded if it's used first time in the process and raises SecurityError.
1 parent 9945a58 commit 9909d34

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

spec/rspec/core/formatters/exception_presenter_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ def read_failed_lines
464464
let(:exception) { instance_double(Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"]) }
465465

466466
it "is handled gracefully" do
467-
with_safe_set_to_level_that_triggers_security_errors do
468-
expect { read_failed_lines }.not_to raise_error
469-
end
467+
expect {
468+
with_safe_set_to_level_that_triggers_security_errors { read_failed_lines }
469+
}.not_to raise_error
470470
end
471471
end
472472

spec/rspec/core/metadata_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ module Core
1717
it "gracefully returns nil if run in a secure thread" do
1818
# Ensure our call to `File.expand_path` is not cached as that is the insecure operation.
1919
Metadata.instance_eval { @relative_path_regex = nil }
20-
with_safe_set_to_level_that_triggers_security_errors do
21-
value = Metadata.relative_path(".")
22-
# on some rubies, File.expand_path is not a security error, so accept "." as well
23-
expect([nil, "."]).to include(value)
20+
21+
value = with_safe_set_to_level_that_triggers_security_errors do
22+
Metadata.relative_path(".")
2423
end
24+
25+
# on some rubies, File.expand_path is not a security error, so accept "." as well
26+
expect([nil, "."]).to include(value)
2527
end
2628

2729
it 'should not transform directories beginning with the same prefix' do

0 commit comments

Comments
 (0)