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
14
14
# stubbed out within tests.
15
15
class File
16
16
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 ) )
19
23
end
20
24
end
21
25
end
22
26
23
27
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 )
25
33
new ( source , path )
26
34
end
27
35
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