Sha256: c779d51caf561a96cad9b65e4261b9df2787b2bff68eacd0599da7043dc5c4d1

Contents?: true

Size: 1.5 KB

Versions: 31

Compression:

Stored size: 1.5 KB

Contents

def mock_client
  return @mock_client if @mock_client
  @mock_client = mock("client")
  @getter = mock("getter")
  @getter.stubs(:get).returns('')
  @mock_client.stubs(:[]).with("describe?xml=true").returns('')
  @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
  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

def stub_add_ds(pid, dsids)
  pid.gsub!(/:/, '%3A')
  dsids.each do |dsid|
    client = mock_client.stubs(:[]).with do |params|
      /objects\/#{pid}\/datastreams\/#{dsid}/.match(params)
    end
    client.returns(stub("ds_adder", :post=>pid, :get=>''))
  end
end

def stub_get_content(pid, dsids)
  pid.gsub!(/:/, '%3A')
  dsids.each do |dsid|
    mock_client.stubs(:[]).with { |params| /objects\/#{pid}\/datastreams\/#{dsid}\/content/.match(params)}.returns(stub("content_accessor", :post=>pid, :get=>''))
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
active-fedora-4.1.0 spec/support/mock_fedora.rb
active-fedora-4.0.0 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc20 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc19 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc18 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc17 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc16 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc15 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc14 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc13 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc12 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc11 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc10 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc9 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc8 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc7 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc6 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc5 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc4 spec/support/mock_fedora.rb
active-fedora-4.0.0.rc3 spec/support/mock_fedora.rb