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

Commit b5f1cda

Browse files
committed
Prevent invalid encoding for files blowing up
1 parent 29f8cd5 commit b5f1cda

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/rspec/support/source.rb

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ class Source
1111
def self.from_file(path)
1212
source = File.read(path)
1313
new(source, path)
14+
# There is no spec for this behaviour as its proven troublesome to
15+
# replicate within our spec suite, to manually verify run
16+
# `bundle exec rspec spec/support/source_spec.broken_example`
17+
rescue Encoding::UndefinedConversionError
18+
new("", path)
1419
end
1520

1621
if String.method_defined?(:encoding)
+8
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+
header = 'привет'
7+
end
8+
end

0 commit comments

Comments
 (0)