File: json_spec.rb

package info (click to toggle)
ruby-postmark 1.25.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 480 kB
  • sloc: ruby: 5,413; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 856 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'spec_helper'

describe Postmark::Json do
  let(:data) { {"bar" => "foo", "foo" => "bar"} }

  shared_examples "json parser" do
    it 'encodes and decodes data correctly' do
      hash = Postmark::Json.decode(Postmark::Json.encode(data))
      expect(hash).to have_key("bar")
      expect(hash).to have_key("foo")
    end
  end

  context "given response parser is JSON" do
    before do
      Postmark.response_parser_class = :Json
    end

    it_behaves_like "json parser"
  end

  context "given response parser is ActiveSupport::JSON" do
    before do
      Postmark.response_parser_class = :ActiveSupport
    end

    it_behaves_like "json parser"
  end

  context "given response parser is Yajl", :skip_for_platform => 'java' do
    before do
      Postmark.response_parser_class = :Yajl
    end

    it_behaves_like "json parser"
  end
end