This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,22 @@ class Source
1414 # stubbed out within tests.
1515 class File
1616 class << self
17- [ :read , :expand_path ] . each do |method_name |
18- define_method ( method_name , &::File . method ( method_name ) )
17+ define_method ( :expand_path , &::File . method ( :expand_path ) )
18+
19+ if RUBY_VERSION . to_f > 1.9
20+ define_method ( :binread , &::File . method ( :binread ) )
21+ else
22+ define_method ( :binread , &::File . method ( :read ) )
1923 end
2024 end
2125 end
2226
2327 def self . from_file ( path )
24- source = File . read ( path )
28+ # We must use `binread` here, there is no spec for this behaviour
29+ # as its proven troublesome to replicate within our spec suite, but
30+ # to manually verify run:
31+ # `bundle exec rspec spec/support/source_broken_example`
32+ source = File . binread ( path )
2533 new ( source , path )
2634 end
2735
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments