spec/support/mock_fedora.rb in active-fedora-4.1.0 vs spec/support/mock_fedora.rb in active-fedora-4.2.0
- old
+ new
@@ -7,17 +7,21 @@
@mock_client
end
def stub_get(pid, datastreams=nil, record_exists=false)
pid.gsub!(/:/, '%3A')
- mock_client.stubs(:[]).with("objects/#{pid}?format=xml").returns(stub('get getter', :get=>'foobar')) if record_exists
- # @mock_client.expects(:[]).with("objects/#{pid}?format=xml").raises(RestClient::ResourceNotFound) unless record_exists
+ if record_exists
+ mock_client.stubs(:[]).with("objects/#{pid}?format=xml").returns(stub('get getter', :get=>'foobar'))
+ else
+ mock_client.stubs(:[]).with("objects/#{pid}?format=xml").raises(RestClient::ResourceNotFound)
+ end
mock_client.stubs(:[]).with("objects/#{pid}/datastreams?format=xml").returns(@getter)
datastreams ||= ['someData', 'withText', 'withText2', 'RELS-EXT']
datastreams.each do |dsid|
mock_client.stubs(:[]).with("objects/#{pid}/datastreams/#{dsid}?format=xml").returns(@getter)
end
end
+
def stub_ingest(pid=nil)
n = pid ? pid.gsub(/:/, '%3A') : nil
mock_client.expects(:[]).with("objects/#{n || 'new'}").returns(stub("ingester", :post=>pid))
end