Sha256: 81f667f042350a78b6c3a02e21799d8bf60e8d8a8d4fd712da10ec8972691c19

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

require File.expand_path(File.dirname(__FILE__)+'/spec_helper')

include Restfully::Parsing

describe Restfully::Parsing do
  class IncludesParsingModule
    include Restfully::Parsing
  end
  it "should make available the serialize and unserialize methods" do
    klass = IncludesParsingModule.new
    klass.should respond_to(:unserialize)
    klass.should respond_to(:serialize)
  end
  it "should raise a ParserNotFound error if the object cannot be parsed" do
    lambda{unserialize("whatever", :content_type => 'unknown')}.should raise_error(Restfully::Parsing::ParserNotFound, "Content-Type 'unknown' is not supported. Cannot parse the given object.")
  end
  it "should correctly unserialize json content" do
    object = {'p1' => 'v1'}
    unserialize(object.to_json, :content_type => 'application/json;charset=utf-8').should == object
  end
  it "should correctly serialize an object into json" do
    object = {'p1' => 'v1'}
    serialize(object, :content_type => 'application/json;charset=utf-8').should == object.to_json
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
restfully-0.5.2 spec/parsing_spec.rb
restfully-0.5.1 spec/parsing_spec.rb
restfully-0.5.0 spec/parsing_spec.rb
restfully-0.4.1 spec/parsing_spec.rb
restfully-0.4.0 spec/parsing_spec.rb
restfully-0.3.2 spec/parsing_spec.rb
restfully-0.3.1 spec/parsing_spec.rb
restfully-0.3.0 spec/parsing_spec.rb