Sha256: 194c834a0a3ccfcb1ecc74c0a50a053f78a4bfacdc30e0f3e9d81527dbf5214d

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

require "spec_helper"

shared_examples "a FaultMessage" do
  let(:response) do
    described_class.from_json(
      {
        :error => [
          {
            :errorId   => 1234,
            :domain    => "PLATFORM",
            :subdomain => "Application",
            :severity  => "Error",
            :category  => "Application",
            :message   => "An error message",
            :parameter => ["X-HEADER-FIELD", "X-OTHER-FIELD"]
          },
          {
            :errorId => 2345
          }
        ]
      }.to_json
    )
  end

  it "maps ['error'][0]['errorId'] to #error_id" do
    expect(response.error_id).to eq(1234)
  end

  it "maps ['error'][0]['domain'] to #error_domain" do
    expect(response.error_domain).to eq("PLATFORM")
  end

  it "maps ['error'][0]['subdomain'] to #error_subdomain" do
    expect(response.error_subdomain).to eq("Application")
  end

  it "maps ['error'][0]['severity'] to #error_severity" do
    expect(response.error_severity).to eq("Error")
  end

  it "maps ['error'][0]['category'] to #error_category" do
    expect(response.error_category).to eq("Application")
  end

  it "maps ['error'][0]['message'] to #error_message" do
    expect(response.error_message).to eq("An error message")
  end

  it "maps ['error'][0]['parameter'][0] to #error_parameters.first" do
    expect(response.error_parameters.first).to eq("X-HEADER-FIELD")
  end

  it "maps ['error'][0]['parameter'][1] to #error_parameters.last" do
    expect(response.error_parameters.last).to eq("X-OTHER-FIELD")
  end

  it "allows access to additional errors via #errors" do
    expect(response.errors.last.id).to eq(2345)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
creative-pp-adaptive-1.1.1 spec/shared/a_fault_message.rb