spec/controllers/terms_controller_spec.rb in qa-0.5.0 vs spec/controllers/terms_controller_spec.rb in qa-0.6.0
- old
+ new
@@ -47,24 +47,38 @@
end
end
describe "#search" do
- before :each do
- stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names").
- with(:headers => {'Accept'=>'application/json'}).
- to_return(:body => webmock_fixture("loc-names-response.txt"), :status => 200)
- end
+ context "loc" do
+ before :each do
+ stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names").
+ with(:headers => {'Accept'=>'application/json'}).
+ to_return(:body => webmock_fixture("loc-names-response.txt"), :status => 200)
+ end
- it "should return a set of terms for a tgnlang query" do
- get :search, {:q => "Tibetan", :vocab => "tgnlang" }
- expect(response).to be_success
+ it "should return a set of terms for a tgnlang query" do
+ get :search, {:q => "Tibetan", :vocab => "tgnlang" }
+ expect(response).to be_success
+ end
+
+ it "should not return 404 if subauthority is valid" do
+ get :search, { :q => "Berry", :vocab => "loc", :subauthority => "names" }
+ expect(response).to be_success
+ end
end
- it "should not return 404 if subauthority is valid" do
- get :search, { :q => "Berry", :vocab => "loc", :subauthority => "names" }
- expect(response).to be_success
+ context "assign_fast" do
+ before do
+ stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word&queryIndex=suggest50&queryReturn=suggest50,idroot,auth,type&rows=20&suggest=autoSubject").
+ with(:headers => {'Accept'=>'application/json'}).
+ to_return(:body => webmock_fixture("assign-fast-topical-result.json"), :status => 200, :headers => {})
+ end
+ it "succeeds if authority class is camelcase" do
+ get :search, { :q => "word", :vocab => "assign_fast", :subauthority => "topical" }
+ expect(response).to be_success
+ end
end
end
describe "#index" do
@@ -101,10 +115,10 @@
context "with supported authorities" do
before do
stub_request(:get, "http://id.loc.gov/authorities/subjects/sh85077565.json").
- with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
+ with(:headers => {'Accept'=>'application/json'}).
to_return(:status => 200, :body => webmock_fixture("loc-names-response.txt"), :headers => {})
end
it "should return an individual state term" do
get :show, { :vocab => "local", :subauthority => "states", id: "OH" }