Sha256: 0afa1216281a2d3fa94576d2f85955e1e262b57eafdc08fca3575d35dfeb241c

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'helper'

describe Faraday::Response::ParseMarshal do
  context 'when used' do
    let(:parse_marshal) { Faraday::Response::ParseMarshal.new }

    it 'should load a marshalled hash' do
      me = parse_marshal.on_complete(:body => "\x04\b{\x06I\"\tname\x06:\x06ETI\"\x17Erik Michaels-Ober\x06;\x00T")
      me.class.should == Hash
    end

    it 'should handle hashes' do
      me = parse_marshal.on_complete(:body => "\x04\b{\x06I\"\tname\x06:\x06ETI\"\x17Erik Michaels-Ober\x06;\x00T")
      me['name'].should == 'Erik Michaels-Ober'
    end
  end

  context 'integration test' do
    let(:stubs) { Faraday::Adapter::Test::Stubs.new }
    let(:connection) do
      Faraday::Connection.new do |builder|
        builder.adapter :test, stubs
        builder.use Faraday::Response::ParseMarshal
      end
    end

    it 'should create a Hash from the body' do
      stubs.get('/hash') {[200, {'content-type' => 'application/xml; charset=utf-8'}, "\x04\b{\x06I\"\tname\x06:\x06ETI\"\x17Erik Michaels-Ober\x06;\x00T"]}
      me = connection.get('/hash').body
      me.class.should == Hash
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faraday_middleware-0.7.0 spec/parse_marshal_spec.rb
faraday_middleware-0.7.0.rc1 spec/parse_marshal_spec.rb
faraday_middleware-0.6.5 spec/parse_marshal_spec.rb