From d4b41f6f171a376648d1ef32ab178dca0685d53a Mon Sep 17 00:00:00 2001 From: Michael Klein Date: Wed, 4 Feb 2015 10:17:32 -0600 Subject: [PATCH] Use FakeWeb for SRU retrieval --- Gemfile | 1 + Gemfile.lock | 2 ++ spec/lib/avalon/bib_retriever_spec.rb | 11 ++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index ee6b7ef93d..40586ac940 100644 --- a/Gemfile +++ b/Gemfile @@ -146,6 +146,7 @@ gem 'shoulda-matchers' gem 'faker' gem 'fakefs', require: "fakefs/safe" + gem 'fakeweb' gem 'hashdiff' end diff --git a/Gemfile.lock b/Gemfile.lock index 996ee48698..d56b2716b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -736,6 +737,7 @@ DEPENDENCIES factory_girl_rails fakefs faker + fakeweb felixwrapper! font-awesome-rails (~> 3.0) haml diff --git a/spec/lib/avalon/bib_retriever_spec.rb b/spec/lib/avalon/bib_retriever_spec.rb index c2ebe43535..a8292886d7 100644 --- a/spec/lib/avalon/bib_retriever_spec.rb +++ b/spec/lib/avalon/bib_retriever_spec.rb @@ -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