-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSpec::Support::Source.from_file crashes in File.read if Encoding.default_internal would cause a lossy conversion #354
Comments
Appreciated. I don't think you can replicate this from "within" a running rspec suite - you would need to run a separate process that is configured in a specific way. |
The error is actually just down to loading a file with bad encoding, I just can't seem to produce the invalid encoding! |
The issue here is in the |
Hm well problem is solved for now with a note explaining how to test :) |
Awesome! |
Does it means we should close this issue? 😊 |
I think it should remain open until #364 can be merged |
Subject of the issue
I was doing work on one of my gems and accidentally removed rack-test from the gemspec. When I try to load rspec (run
bundle exec rspec
) RSpec instead of telling me whichrequire()
has failed raises an encoding error inRSpec::Support::Source.from_file
. The encoding error is very non-descriptive and obscures the actual issue at hand (missing dependency). This results in a backtrace like thisYour environment
Outputting
at the head of the method prints
Steps to reproduce
Create the following spec file in an empty directory:
spec/boom_spec.rb
:and add a Gemfile with the usual stanza
Run bundle install and then
bundle exec rspec
as per usual.Expected behavior
For the given spec, the spec runner tells me that the
UndeclaredModule
is a missing constant (or something descriptive at least).Actual behavior
Rspec runner will crash with an encoding error in
File.read
.Recommended fix
Change
File.read
toFile.binread
. As it stands the source reader is not internal encoding resilient - it expects that Ruby will be able to read the file correctly and convert it, but since the conversion in this case would be lossy (UTF8 source to ASCII internal) Ruby raises an error.The text was updated successfully, but these errors were encountered: