Sha256: 022cc55ceb7f92f390b94e972e13bf9a2049780c5f5e593248f04d78f3be8a40

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

describe ChatWork::Client do
  describe "#initialize" do
    subject do
      ChatWork::Client.new(
        api_key:      api_key,
        access_token: access_token,
        api_base:     api_base,
        api_version:  api_version,
      )
    end

    let(:api_key)      { nil }
    let(:access_token) { nil }
    let(:api_base)     { "https://api.chatwork.com/" }
    let(:api_version)  { "/v2" }

    context "with api_key" do
      let(:api_key) { "my_api_key" }

      it "client has X-ChatWorkToken header" do
        connection = subject.instance_variable_get(:@conn)

        expect(connection.headers["X-ChatWorkToken"]).to eq "my_api_key"
      end
    end

    context "with access_token" do
      let(:access_token) { "my_access_token" }

      it "client has Authorization header" do
        connection = subject.instance_variable_get(:@conn)

        expect(connection.headers["Authorization"]).to eq "Bearer my_access_token"
      end
    end

    context "without both api_key and access_token" do
      it { expect { subject }.to raise_error "Either api_key or access_token is required" }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
chatwork-1.0.1 spec/lib/chatwork/client_spec.rb
chatwork-1.0.0 spec/lib/chatwork/client_spec.rb
chatwork-0.12.3 spec/lib/chatwork/client_spec.rb
chatwork-0.12.2 spec/lib/chatwork/client_spec.rb
chatwork-0.12.1 spec/lib/chatwork/client_spec.rb
chatwork-0.12.0 spec/lib/chatwork/client_spec.rb
chatwork-0.11.0 spec/lib/chatwork/client_spec.rb
chatwork-0.10.0 spec/lib/chatwork/client_spec.rb
chatwork-0.9.0 spec/lib/chatwork/client_spec.rb
chatwork-0.8.0 spec/lib/chatwork/client_spec.rb