File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 2
2
require 'test/unit'
3
3
4
4
class TestEnv < Test ::Unit ::TestCase
5
- IGNORE_CASE = /bccwin|mswin|mingw/ =~ RUBY_PLATFORM
5
+ windows = /bccwin|mswin|mingw/ =~ RUBY_PLATFORM
6
+ IGNORE_CASE = windows
7
+ ENCODING = windows ? Encoding ::UTF_8 : Encoding . find ( "locale" )
6
8
PATH_ENV = "PATH"
7
9
INVALID_ENVVARS = [
8
10
"foo\0 bar" ,
@@ -361,7 +363,7 @@ def test_inspect_encoding
361
363
ENV . clear
362
364
key = "VAR\u{e5 e1 e2 e4 e3 101 3042} "
363
365
ENV [ key ] = "foo"
364
- assert_equal ( %{{"VAR \u{e5 e1 e2 e4 e3 101 3042} " => "foo"}} , ENV . inspect )
366
+ assert_equal ( %{{#{ ( key . encode ( ENCODING ) rescue key . b ) . inspect } => "foo"}} , ENV . inspect )
365
367
end
366
368
367
369
def test_to_a
@@ -409,8 +411,7 @@ def test_assoc
409
411
assert_equal ( "foo" , v )
410
412
end
411
413
assert_invalid_env { |var | ENV . assoc ( var ) }
412
- encoding = /mswin|mingw/ =~ RUBY_PLATFORM ? Encoding ::UTF_8 : Encoding . find ( "locale" )
413
- assert_equal ( encoding , v . encoding )
414
+ assert_equal ( ENCODING , v . encoding )
414
415
end
415
416
416
417
def test_has_value2
@@ -524,7 +525,7 @@ def test_huge_value
524
525
assert_equal ( huge_value , ENV [ "foo" ] )
525
526
end
526
527
527
- if /mswin|mingw/ =~ RUBY_PLATFORM
528
+ if windows
528
529
def windows_version
529
530
@windows_version ||= %x[ver] [ /Version (\d +)/ , 1 ] . to_i
530
531
end
You can’t perform that action at this time.
0 commit comments