Sha256: d35415100ab7c29aace2b6571b4c9586278a6f8f2d2b2a6657016a26c9f75744

Contents?: true

Size: 1.6 KB

Versions: 3

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'

describe DNSimple::ExtendedAttribute do

  describe ".find" do
    before do
      stub_request(:get, %r[/v1/extended_attributes/com]).
          to_return(read_fixture("extended_attributes/success.http"))
    end

    it "builds the correct request" do
      described_class.find("com")

      WebMock.should have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/extended_attributes/com").
                     with(:headers => { 'Accept' => 'application/json' })
    end

    context "when the TLD has no attributes" do
      before do
        stub_request(:get, %r[/v1/extended_attributes/com]).
            to_return(read_fixture("extended_attributes/com.http"))
      end

      it "returns an empty list" do
        result = described_class.find("com")

        expect(result).to eq([])
      end
    end

    context "when the TLD has attributes" do
      before do
        stub_request(:get, %r[/v1/extended_attributes/ca]).
            to_return(read_fixture("extended_attributes/ca.http"))
      end

      it "returns the attributes" do
        result = described_class.find("ca")

        expect(result).to be_a(Array)
        expect(result).to have(5).attributes

        attribute = result[0]
        expect(attribute).to be_a(described_class)
        expect(attribute.name).to eq("cira_legal_type")
        expect(attribute.description).to eq("Legal type of registrant contact")
        expect(attribute.required).to be_true
        expect(attribute.options).to be_a(Array)
        expect(attribute.options).to have(18).options
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dnsimple-ruby-1.5.3 spec/dnsimple/extended_attributes_spec.rb
dnsimple-ruby-1.5.2 spec/dnsimple/extended_attributes_spec.rb
dnsimple-ruby-1.5.1 spec/dnsimple/extended_attributes_spec.rb