Skip to content

Commit

Permalink
Rename safely to make it more clear what it’s for.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Mar 18, 2015
1 parent f98223d commit 4a61665
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion spec/rspec/core/backtrace_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def make_backtrace_formatter(exclusion_patterns=nil, inclusion_patterns=nil)
end

it "deals gracefully with a security error" do
safely do
with_safe_set_to_level_that_triggers_security_errors do
self.formatter.__send__(:backtrace_line, __FILE__)
# on some rubies, this doesn't raise a SecurityError; this test just
# assures that if it *does* raise an error, the error is caught inside
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/formatters/snippet_extractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Formatters

it "falls back on a default message when it gets a security error" do
message = nil
safely do
with_safe_set_to_level_that_triggers_security_errors do
message = RSpec::Core::Formatters::SnippetExtractor.new.lines_around("blech", 8)
end
expect(message).to eq("# Couldn't get snippet for blech")
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Core
end
# I have no idea what line = line.sub(/\A([^:]+:\d+)$/, '\\1') is supposed to do
it "gracefully returns nil if run in a secure thread" do
safely do
with_safe_set_to_level_that_triggers_security_errors do
value = Metadata.relative_path(".")
# on some rubies, File.expand_path is not a security error, so accept "." as well
expect([nil, "."]).to include(value)
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
let(:exception) { instance_double(Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"]) }

it "is handled gracefully" do
safely do
with_safe_set_to_level_that_triggers_security_errors do
expect { notification.send(:read_failed_line) }.not_to raise_error
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/helper_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def ignoring_warnings
result
end

def safely
def with_safe_set_to_level_that_triggers_security_errors

This comment has been minimized.

Copy link
@xaviershay

xaviershay Mar 18, 2015

Member

haha, yep that's a descriptive name!

Thread.new do
ignoring_warnings { $SAFE = 3 }
yield
Expand Down

0 comments on commit 4a61665

Please sign in to comment.