Sha256: b0544f7d7bc5137f8487859a8cca571cb19a7e2ab8733a5243f29e0738be752e
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
require 'spec_helper' describe Dnsimple::Client, ".identity" do subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").identity } describe "#whoami" do before do stub_request(:get, %r{/v2/whoami$}). to_return(read_http_fixture("whoami/success.http")) end it "builds the correct request" do subject.whoami expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/whoami"). with(headers: { 'Accept' => 'application/json' }) end it "returns the whoami" do response = subject.whoami expect(response).to be_a(Dnsimple::Response) result = response.data expect(result).to be_a(Dnsimple::Struct::Whoami) end context "when authenticated as account" do before do stub_request(:get, %r{/v2/whoami$}). to_return(read_http_fixture("whoami/success_account.http")) end it "sets the account" do result = subject.whoami.data expect(result.account).to be_a(Dnsimple::Struct::Account) expect(result.user).to be_nil end end context "when authenticated as user" do before do stub_request(:get, %r{/v2/whoami$}). to_return(read_http_fixture("whoami/success_user.http")) end it "sets the user" do result = subject.whoami.data expect(result.account).to be_nil expect(result.user).to be_a(Dnsimple::Struct::User) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dnsimple-4.0.0 | spec/dnsimple/client/identity_spec.rb |
dnsimple-3.1.0 | spec/dnsimple/client/identity_spec.rb |