spec/yaml_spec.rb in asir-1.2.6 vs spec/yaml_spec.rb in asir-1.2.7

- old
+ new

@@ -1,10 +1,10 @@ require File.expand_path('../spec_helper', __FILE__) require 'asir/coder/yaml' describe "ASIR::Coder::Yaml" do - before(:each) do + before(:each) do @enc = ASIR::Coder::Yaml.new @dec = @enc.dup end basic_objs = [ ] @@ -18,13 +18,10 @@ 'String', [ :Symbol, ':Symbol' ], ].each do | x | x, str = *x if x == nil - if RUBY_VERSION == '1.9.2' - str = '!!null ' - end end str ||= x.to_s unless x == nil and RUBY_VERSION !~ /^1\.8/ and RUBY_ENGINE =~ /jruby/i str = " #{str}" end @@ -92,16 +89,21 @@ str.encoding.inspect.should == "#<Encoding:ASCII-8BIT>" yaml = ::YAML.dump(str) case RUBY_VERSION when '1.9.2' - yaml.should == "--- ! '#<Encoding:ASCII-8BIT>'\n" + yaml.should == "--- \"#<Encoding:ASCII-8BIT>\"\n" else yaml.should == "--- !binary |-\n IzxFbmNvZGluZzpBU0NJSS04QklUPg==\n" end - yaml = ::YAML.dump(str, nil, :never_binary => true) + case RUBY_VERSION + when '1.9.2' + yaml = ::YAML.dump(str) + else + yaml = ::YAML.dump(str, nil, :never_binary => true) + end yaml.should =~ /\A--- (! )?['"]\#<Encoding:ASCII-8BIT>['"]\n/ end it 'should handle :never_binary options.' do str = '8bitascii'.force_encoding('ASCII-8BIT') @@ -112,11 +114,11 @@ when '1.9.2' case RUBY_ENGINE when /jruby/i out.should == "--- 8bitascii\n" else - out.should == "--- 8bitascii\n...\n" + out.should == "--- 8bitascii\n" end else out.should == "--- !binary |-\n OGJpdGFzY2lp\n" end @dec.prepare.decode(str).should == str @@ -126,10 +128,15 @@ out = @enc.prepare.encode(str) case RUBY_ENGINE when /jruby/i out.should == "--- 8bitascii\n" else - out.should == "--- 8bitascii\n...\n" + case RUBY_VERSION + when /^1\.8|^1\.9\.2/ + out.should == "--- 8bitascii\n" + else + out.should == "--- 8bitascii\n...\n" + end end inp = @dec.prepare.decode(str) inp.should == str inp.encoding.inspect.should == "#<Encoding:UTF-8>" end