Sha256: 14a31127f74f533848c6270cb0b80bc3987cc43c17b5984f0cf72875f995e6dc

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'
require 'cuba_api/config'
require 'cuba_api/loggers'
require 'cuba_api/aspects'
require 'cuba_api/aspects/serializer'
require 'yaml'
require 'ixtlan/babel/serializer'

class A
  def attributes
    { :name => 'me and the corner' }
  end
end
class ASerializer < Ixtlan::Babel::Serializer
end
module ToYaml
  def to_yaml( obj, opts )
    obj.to_yaml
  end
end

describe CubaApi::Serializer do

  before do
    Cuba.reset!
    Cuba.plugin CubaApi::Config
    Cuba[ :aspects ] = []
    Cuba.plugin CubaApi::Loggers
    Cuba.plugin CubaApi::Aspects
    Cuba.plugin CubaApi::Serializer
    Cuba.plugin ToYaml
    Cuba.append_aspect :to_yaml
    Cuba.define do
      on default do
        write A.new
      end
    end
  end

  it 'should write out yaml' do
    skip("to_yaml add extra line with ...") if defined?( JRUBY_VERSION ) and (( JRUBY_VERSION =~ /^1.6./ ) == 0 ) and ( nil == (RUBY_VERSION =~ /^1.8/) )
     _, _, resp = Cuba.call({})

    resp[ 0 ] = resp[ 0 ].sub(/.*\n/, "---\n")
    resp.must_equal ["---\nname: me and the corner\n"]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cuba-api-0.6.3 spec/serializer_spec.rb
cuba-api-0.6.2 spec/serializer_spec.rb