Sha256: 8db9e506337db9c9a4d251b34da78bf5b966b17623b88bf708798bd3951592b5

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

require 'rubygems'
require 'test/unit'
require 'shoulda'
require 'modern_times'

class Klass
  def initialize(str)
    @str = str
  end
  def hello
    @str
  end
end

class MarshalStrategyTest < Test::Unit::TestCase
  context '' do
    setup do
      @bson   = Object.new
      @json   = Object.new
      @ruby   = Object.new
      @string = Object.new
      @bson.extend   ModernTimes::MarshalStrategy::BSON
      @json.extend   ModernTimes::MarshalStrategy::JSON
      @ruby.extend   ModernTimes::MarshalStrategy::Ruby
      @string.extend ModernTimes::MarshalStrategy::String
    end

    should 'marshal and unmarshal correctly' do
      hash = {'foo' => 42, 'bar' => 'zulu'}
      str  = 'abcdef1234'
      obj  = Klass.new('hello')
      assert_equal hash, @bson.unmarshal(@bson.marshal(hash))
      assert_equal hash, @json.unmarshal(@json.marshal(hash))
      assert_equal hash, @ruby.unmarshal(@ruby.marshal(hash))
      assert_equal str,  @string.unmarshal(@string.marshal(str))
      assert_equal obj.hello,  @ruby.unmarshal(@ruby.marshal(obj)).hello
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
modern_times-0.2.10 test/marshal_strategy_test.rb
modern_times-0.2.9 test/marshal_strategy_test.rb
modern_times-0.2.8 test/marshal_strategy_test.rb
modern_times-0.2.7 test/marshal_strategy_test.rb
modern_times-0.2.6 test/marshal_strategy_test.rb
modern_times-0.2.5 test/marshal_strategy_test.rb
modern_times-0.2.4 test/marshal_strategy_test.rb
modern_times-0.2.3 test/marshal_strategy_test.rb
modern_times-0.2.2 test/marshal_strategy_test.rb
modern_times-0.2.1 test/marshal_strategy_test.rb
modern_times-0.2.0 test/marshal_strategy_test.rb