Sha256: 69a090d07ff8776e8d32e76cea5aaea88f9ab2ad05646e2f589ed1569a5348ee

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe Qa::Authorities::Loc do
  
  before :all do
    stub_request(:get, "http://id.loc.gov/search/?format=json&q=haw*&q=cs:http://id.loc.gov/vocabulary/geographicAreas").
      with(:headers => {'Accept'=>'application/json'}).
      to_return(:body => webmock_fixture("loc-response.txt"), :status => 200)
    @authority = Qa::Authorities::Loc.new
    @authority.search("haw*", "geographicAreas")
  end
  
  it "should instantiate with a query and return data" do
    expect(@authority).not_to be_nil
    @authority.raw_response.to_s.should include("id")
  end  
  
  it "should return a sub_authority url" do
    @authority.should_not be_nil
    url = @authority.sub_authorityURL("geographicAreas")
    expect(url).not_to be_nil
  end
  
  it "should not return a url for an invalid sub_authority" do
    @authority.should_not be_nil
    url = @authority.sub_authorityURL("invalid sub_authority")
    expect(url).to eq("")
  end
  
  it "should return JSON" do
    @authority.should_not be_nil
    json = @authority.parse_authority_response(@authority.raw_response)
    expect(json).not_to be_empty
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qa-0.0.3 spec/lib/authorities_loc_spec.rb
qa-0.0.2 spec/lib/authorities_loc_spec.rb