File tree Expand file tree Collapse file tree 10 files changed +43
-17
lines changed Expand file tree Collapse file tree 10 files changed +43
-17
lines changed Original file line number Diff line number Diff line change 1
- require_relative '../../ spec_helper'
1
+ require_relative 'spec_helper'
2
2
require_relative 'shared/each'
3
3
4
4
describe "ENV.each_pair" do
Original file line number Diff line number Diff line change 1
- require_relative '../../ spec_helper'
1
+ require_relative 'spec_helper'
2
2
require_relative 'shared/each'
3
3
4
4
describe "ENV.each" do
Original file line number Diff line number Diff line change 1
- require_relative '../../ spec_helper'
1
+ require_relative 'spec_helper'
2
2
require_relative '../enumerable/shared/enumeratorized'
3
3
4
4
describe "ENV.each_value" do
26
26
27
27
it "uses the locale encoding" do
28
28
ENV . each_value do |value |
29
- value . encoding . should == Encoding . find ( 'locale' )
29
+ value . should . be_locale_env
30
30
end
31
31
end
32
32
Original file line number Diff line number Diff line change 35
35
@internal = Encoding . default_internal
36
36
37
37
Encoding . default_external = Encoding ::BINARY
38
-
39
- @locale_encoding = Encoding . find "locale"
40
38
end
41
39
42
40
after :each do
48
46
Encoding . default_internal = nil
49
47
50
48
ENV . send ( @method ) do |key , value |
51
- key . encoding . should equal ( @locale_encoding )
52
- value . encoding . should equal ( @locale_encoding )
49
+ key . should . be_locale_env
50
+ value . should . be_locale_env
53
51
end
54
52
end
55
53
Original file line number Diff line number Diff line change 15
15
end
16
16
17
17
it "uses the locale encoding for keys" do
18
- ENV . send ( @method ) . keys . all? { |k | k . encoding == Encoding . find ( 'locale' ) } . should be_true
18
+ ENV . send ( @method ) . keys . each { |k | k . should . be_locale_env }
19
19
end
20
20
21
21
it "uses the locale encoding for values" do
22
- ENV . send ( @method ) . values . all? { |v | v . encoding == Encoding . find ( 'locale' ) } . should be_true
22
+ ENV . send ( @method ) . values . each { |k | k . should . be_locale_env }
23
23
end
24
24
25
25
it "duplicates the ENV when converting to a Hash" do
Original file line number Diff line number Diff line change
1
+ require_relative '../../spec_helper'
2
+
3
+ class BeLocaleEnvEncodingString
4
+ def initialize ( name = 'locale' )
5
+ encoding = Encoding . find ( name )
6
+ @encodings = ( encoding = Encoding ::US_ASCII ) ?
7
+ [ encoding , Encoding ::ASCII_8BIT ] : [ encoding ]
8
+ end
9
+
10
+ def matches? ( actual )
11
+ @actual = actual = actual . encoding
12
+ @encodings . include? ( actual )
13
+ end
14
+
15
+ def failure_message
16
+ [ "Expected #{ @actual } to be #{ @encodings . join ( ' or ' ) } " ]
17
+ end
18
+
19
+ def negative_failure_message
20
+ [ "Expected #{ @actual } not to be #{ @encodings . join ( ' or ' ) } " ]
21
+ end
22
+ end
23
+
24
+ class String
25
+ def be_locale_env ( expected = 'locale' )
26
+ BeLocaleEnvEncodingString . new ( expected )
27
+ end
28
+ end
Original file line number Diff line number Diff line change 1
- require_relative '../../ spec_helper'
1
+ require_relative 'spec_helper'
2
2
3
3
describe "ENV.to_a" do
4
4
11
11
12
12
it "returns the entries in the locale encoding" do
13
13
ENV . to_a . each do |key , value |
14
- key . encoding . should == Encoding . find ( 'locale' )
15
- value . encoding . should == Encoding . find ( 'locale' )
14
+ key . should . be_locale_env
15
+ value . should . be_locale_env
16
16
end
17
17
end
18
18
end
Original file line number Diff line number Diff line change 1
- require_relative '../../ spec_helper'
1
+ require_relative 'spec_helper'
2
2
require_relative 'shared/to_hash'
3
3
4
4
describe "ENV.to_h" do
Original file line number Diff line number Diff line change 1
- require_relative '../../ spec_helper'
1
+ require_relative 'spec_helper'
2
2
require_relative 'shared/to_hash'
3
3
4
4
describe "ENV.to_hash" do
Original file line number Diff line number Diff line change 1
- require_relative '../../ spec_helper'
1
+ require_relative 'spec_helper'
2
2
3
3
describe "ENV.values" do
4
4
8
8
9
9
it "uses the locale encoding" do
10
10
ENV . values . each do |value |
11
- value . encoding . should == Encoding . find ( 'locale' )
11
+ value . should . be_locale_env
12
12
end
13
13
end
14
14
end
You can’t perform that action at this time.
0 commit comments