Sha256: 44fd58ad98c8d17ca270d51d71f12a83d0d6448e10d1cbe089a28a58dce660e5

Contents?: true

Size: 908 Bytes

Versions: 13

Compression:

Stored size: 908 Bytes

Contents

require 'spec_helper'

describe Docker::Util do
  subject { described_class }

  describe '.parse_json' do
    subject { described_class.parse_json(arg) }

    context 'when the argument is nil' do
      let(:arg) { nil }

      it { should be_nil }
    end

    context 'when the argument is empty' do
      let(:arg) { '' }

      it { should be_nil }
    end

    context 'when the argument is \'null\'' do
      let(:arg) { 'null' }

      it { should be_nil }
    end

    context 'when the argument is not valid JSON' do
      let(:arg) { '~~lol not valid json~~' }

      it 'raises an error' do
        expect { subject }.to raise_error Docker::Error::UnexpectedResponseError
      end
    end

    context 'when the argument is valid JSON' do
      let(:arg) { '{"yolo":"swag"}' }

      it 'parses the JSON into a Hash' do
        subject.should == { 'yolo' => 'swag' }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
docker-api-1.6.0 spec/docker/util_spec.rb
docker-api-1.5.4 spec/docker/util_spec.rb
docker-api-1.5.3 spec/docker/util_spec.rb
docker-api-1.5.2 spec/docker/util_spec.rb
docker-api-1.5.1 spec/docker/util_spec.rb
docker-api-1.5.0 spec/docker/util_spec.rb
docker-api-1.4.0 spec/docker/util_spec.rb
docker-api-1.3.1 spec/docker/util_spec.rb
docker-api-1.3.0 spec/docker/util_spec.rb
docker-api-1.2.0 spec/docker/util_spec.rb
docker-api-1.1.2 spec/docker/util_spec.rb
docker-api-1.1.1 spec/docker/util_spec.rb
docker-api-1.1.0 spec/docker/util_spec.rb