Sha256: 764f6ec8338d134ad07020ff7e06db40ded76af7eeab53bc20049d0977392e8a

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'
module Queuel
  module Serialization
    module Json
      describe Decoder do
        let(:body) { '{"name":"jon"}' }
        subject { described_class.new body }

        it "can call from the class" do
          described_class.call(body).should == { name: "jon" }
        end

        it "can decode from instance" do
          subject.decode.should == { name: "jon" }
        end

        describe "with bad body" do
          let(:body) { '{"name":"jon"' }

          it "fails on bad body" do
            expect { subject.decode }.to raise_error SerializationError
          end
        end
      end

      describe Encoder do
        let(:encoded_body) { '{"name":"jon"}' }
        let(:body) { { "name" => "jon" } }
        subject { described_class.new body }

        it "can call from the class" do
          described_class.call(body).should == encoded_body
        end

        it "can decode from instance" do
          subject.encode.should == encoded_body
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
queuel-0.4.8 spec/lib/queuel/serialization/json_spec.rb
queuel-0.4.6 spec/lib/queuel/serialization/json_spec.rb
queuel-0.4.5 spec/lib/queuel/serialization/json_spec.rb
queuel-0.4.4 spec/lib/queuel/serialization/json_spec.rb
queuel-0.4.3 spec/lib/queuel/serialization/json_spec.rb
queuel-0.4.2 spec/lib/queuel/serialization/json_spec.rb
queuel-0.4.1 spec/lib/queuel/serialization/json_spec.rb
queuel-0.4.0 spec/lib/queuel/serialization/json_spec.rb
queuel-0.3.1 spec/lib/queuel/serialization/json_spec.rb
queuel-0.3.0 spec/lib/queuel/serialization/json_spec.rb
queuel-0.2.0 spec/lib/queuel/serialization/json_spec.rb