diff --git a/lib/rspec/support/source.rb b/lib/rspec/support/source.rb index b9e07cdda..54ec6af27 100644 --- a/lib/rspec/support/source.rb +++ b/lib/rspec/support/source.rb @@ -11,6 +11,11 @@ class Source def self.from_file(path) source = File.read(path) new(source, path) + # There is no spec for this behaviour as its proven troublesome to + # replicate within our spec suite, to manually verify run + # `bundle exec rspec spec/support/source_spec.broken_example` + rescue Encoding::UndefinedConversionError + new("", path) end if String.method_defined?(:encoding) diff --git a/spec/support/source_spec.broken_example b/spec/support/source_spec.broken_example new file mode 100644 index 000000000..3f88f352d --- /dev/null +++ b/spec/support/source_spec.broken_example @@ -0,0 +1,8 @@ +Encoding.default_internal = Encoding::BINARY + +describe UndeclaredModule do + # the missing constant can be anything + it 'crashes and does not even parse this' do + header = 'привет' + end +end