spec/yaml_spec.rb in asir-1.1.8 vs spec/yaml_spec.rb in asir-1.1.9
- old
+ new
@@ -17,10 +17,13 @@
123.45,
'String',
[ :Symbol, ':Symbol' ],
].each do | x |
x, str = *x
+ if x == nil and RUBY_VERSION == '1.9.2'
+ str = '!!null '
+ end
str ||= x.to_s
str = "--- #{str}\n"
str << "...\n" if RUBY_VERSION !~ /^1\.8/
basic_objs << [ x, str ]
it "should handle #{x.inspect}" do
@@ -35,16 +38,18 @@
out = do_message
out.should =~ /^ :ascii_8bit: hostname/m
case RUBY_VERSION
when /^1\.8/
out.should =~ /^ :binary: !binary /m
+ when '1.9.2'
+ out.should =~ /^ :binary: |-\n/m
else
out.should =~ /^ :binary: ! "\\x04/m
end
end
- it 'should handle :ascii_8bit_ok.' do
+ it 'should handle :ASCII_8BIT_ok.' do
@enc.yaml_options = { :ASCII_8BIT_ok => true }
out = do_message
out.should =~ /^ :ascii_8bit: hostname/m
out.should =~ /^ :binary: !binary /m
end
@@ -78,21 +83,31 @@
str = enc.inspect
str.force_encoding(hostname.encoding)
str.encoding.inspect.should == "#<Encoding:ASCII-8BIT>"
yaml = ::YAML.dump(str)
- yaml.should == "--- !binary |-\n IzxFbmNvZGluZzpBU0NJSS04QklUPg==\n"
+ case RUBY_VERSION
+ when '1.9.2'
+ yaml.should == "--- ! '#<Encoding:ASCII-8BIT>'\n"
+ else
+ yaml.should == "--- !binary |-\n IzxFbmNvZGluZzpBU0NJSS04QklUPg==\n"
+ end
yaml = ::YAML.dump(str, nil, :never_binary => true)
yaml.should == "--- ! '#<Encoding:ASCII-8BIT>'\n"
end
it 'should handle :never_binary options.' do
str = '8bitascii'.force_encoding('ASCII-8BIT')
@enc.yaml_options = @dec.yaml_options = nil
out = @enc.prepare.encode(str)
- out.should == "--- !binary |-\n OGJpdGFzY2lp\n"
+ case RUBY_VERSION
+ when '1.9.2'
+ out.should == "--- 8bitascii\n...\n"
+ else
+ out.should == "--- !binary |-\n OGJpdGFzY2lp\n"
+ end
@dec.prepare.decode(str).should == str
@enc.yaml_options = { :never_binary => true }
@dec.yaml_options = @enc.yaml_options
out = @enc.prepare.encode(str)