Sha256: 735b817d524239ee6ca78a2b59ab27fc7d8a03718025ba1c294779566f67c2b1

Contents?: true

Size: 816 Bytes

Versions: 1

Compression:

Stored size: 816 Bytes

Contents

describe ChatWork::ChatWorkError do
  describe ".from_response" do
    subject { ChatWork::ChatWorkError.from_response(status, body, headers) }

    context "with WWW-Authenticate header" do
      let(:status) { 401 }

      let(:body) do
        json =
          <<-JSON
            {"errors":["Invalid API Token"]}
          JSON
        Hashie::Mash.new(JSON.parse(json))
      end

      let(:headers) do
        {
          "WWW-Authenticate" => 'Bearer error="invalid_token", error_description="The access token expired"',
        }
      end

      it { should be_an_instance_of ChatWork::AuthenticateError }
      its(:error) { should eq "invalid_token" }
      its(:error_description) { should eq "The access token expired" }
      its(:error_response) { should eq ["Invalid API Token"] }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chatwork-0.6.0 spec/lib/chatwork/chatwork_error_spec.rb