Sha256: 5120659a356d96d2b9fb537abee5aeea7017b34750d9b5ab812167d6b8afb760

Contents?: true

Size: 665 Bytes

Versions: 11

Compression:

Stored size: 665 Bytes

Contents

require "spec_helper"

module Koala::HTTPService
  RSpec.describe Response do
    describe "#data" do
      it "returns nothing if the body is empty" do
        expect(Response.new(200, "", {}).data).to be_nil
      end

      it "parses the JSON if there's a body" do
        result = {"foo" => "bar"}
        expect(Response.new(200, result.to_json, {}).data).to eq(result)
      end

      it "allows raw values" do
        expect(Response.new(200, "true", {}).data).to be true
      end

      it "raises a ParserError if it's invalid JSON" do
        expect { Response.new(200, "{", {}).data }.to raise_exception(JSON::ParserError)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
koala-3.6.0 spec/cases/http_service/response_spec.rb
koala-3.5.0 spec/cases/http_service/response_spec.rb
koala-3.4.0 spec/cases/http_service/response_spec.rb
koala-3.3.0 spec/cases/http_service/response_spec.rb
koala-3.2.0 spec/cases/http_service/response_spec.rb
koala-3.1.0 spec/cases/http_service/response_spec.rb
koala-3.0.0 spec/cases/http_service/response_spec.rb
koala-3.0.0.rc2 spec/cases/http_service/response_spec.rb
koala-3.0.0.rc spec/cases/http_service/response_spec.rb
koala-3.0.0.beta3 spec/cases/http_service/response_spec.rb
koala-3.0.0.beta2 spec/cases/http_service/response_spec.rb