Skip to content

Commit

Permalink
Use FakeWeb for SRU retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
mbklein authored and bkeese committed Mar 2, 2015
1 parent ce3b6a3 commit d4b41f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -146,6 +146,7 @@
gem 'shoulda-matchers'
gem 'faker'
gem 'fakefs', require: "fakefs/safe"
gem 'fakeweb'
gem 'hashdiff'
end

Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -310,6 +310,7 @@ GEM
fakefs (0.6.0)
faker (1.4.3)
i18n (~> 0.5)
fakeweb (1.3.0)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
fastercsv (1.5.5)
Expand Down Expand Up @@ -736,6 +737,7 @@ DEPENDENCIES
factory_girl_rails
fakefs
faker
fakeweb
felixwrapper!
font-awesome-rails (~> 3.0)
haml
Expand Down
11 changes: 8 additions & 3 deletions spec/lib/avalon/bib_retriever_spec.rb
Expand Up @@ -20,14 +20,19 @@
let(:mods) { File.read(File.expand_path("../../../fixtures/#{bib_id}.mods",__FILE__)) }

describe 'sru' do
let(:sru_url) { "http://zgate.example.edu:9000/db?version=1.1&operation=searchRetrieve&maximumRecords=1&recordSchema=marcxml&query=rec.id=%5E%25#{bib_id}" }
let(:sru_response) { File.read(File.expand_path("../../../fixtures/#{bib_id}.xml",__FILE__)) }

before :each do
Avalon::Configuration['bib_retriever'] = { 'protocol' => 'sru', 'url' => 'http://zgate.example.edu:9000/db' }
FakeWeb.register_uri :get, sru_url, body: sru_response
end

after :each do
FakeWeb.clean_registry
end

let(:sru_url) { "http://zgate.example.edu:9000/db?version=1.1&operation=searchRetrieve&maximumRecords=1&recordSchema=marcxml&query=rec.id=%5E%25#{bib_id}" }
let(:sru_response) { File.read(File.expand_path("../../../fixtures/#{bib_id}.xml",__FILE__)) }
it 'retrieves proper MODS' do
RestClient.should_receive(:get).with(sru_url).and_return(sru_response)
response = Avalon::BibRetriever.instance.get_record("^%#{bib_id}")
expect(Nokogiri::XML(response)).to be_equivalent_to(mods)
end
Expand Down

0 comments on commit d4b41f6

Please sign in to comment.