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

Commit e21c40b

Browse files
committed
Prevent invalid encoding for files blowing up
1 parent c316afd commit e21c40b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/rspec/support/source.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ class << self
2121
end
2222

2323
def self.from_file(path)
24-
source = File.read(path)
24+
# We must use `binread` here, there is no spec for this behaviour
25+
# as its proven troublesome to replicate within our spec suite, but
26+
# to manually verify run:
27+
# `bundle exec rspec spec/support/source_broken_example`
28+
source = File.binread(path)
2529
new(source, path)
2630
end
2731

spec/support/source_broken_example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Encoding.default_internal = Encoding::BINARY
2+
3+
describe UndeclaredModule do
4+
# the missing constant can be anything
5+
it 'crashes and does not even parse this' do
6+
'привет'
7+
end
8+
end

0 commit comments

Comments
 (0)