Sha256: 8cdd742609c63f551014f1728220c4d3752019464395de176e6a6041bc0ad70c

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe Ldp::Resource::BinarySource do
  let(:client) { instance_double(Ldp::Client) }
  let(:uri) { 'http://example.com/foo/bar' }
  let(:content) { 'somecontent' }
  subject { described_class.new(client, uri, content) }

  it "should not display content to inspect" do
    expect(subject.inspect).to match /subject=\"http:\/\/example\.com\/foo\/bar\"/
    expect(subject.inspect).not_to match /somecontent/
  end

  describe '#described_by' do
    context 'without a description' do
      before do
        allow(client).to receive(:head).and_return(instance_double(Ldp::Response, links: { }))
      end

      it 'retrieves the description object' do
        expect(subject.described_by).to eq nil
      end
    end

    context 'with a description' do
      before do
        allow(client).to receive(:head).and_return(instance_double(Ldp::Response, links: { 'describedby' => ['http://example.com/foo/bar/desc']}))
        allow(client).to receive(:find_or_initialize).with('http://example.com/foo/bar/desc').and_return(desc)
      end

      let(:desc) { double }

      it 'retrieves the description object' do
        expect(subject.described_by).to eq desc
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ldp-1.0.0 spec/lib/ldp/resource/binary_source_spec.rb
ldp-0.7.2 spec/lib/ldp/resource/binary_source_spec.rb
ldp-0.7.1 spec/lib/ldp/resource/binary_source_spec.rb
ldp-0.7.0 spec/lib/ldp/resource/binary_source_spec.rb
ldp-0.6.4 spec/lib/ldp/resource/binary_source_spec.rb
ldp-0.6.3 spec/lib/ldp/resource/binary_source_spec.rb
ldp-0.6.2 spec/lib/ldp/resource/binary_source_spec.rb