Sha256: 2caf960ba3bee36acced4a92702994d7f3ec0e748109bb50240bbd64625814b1

Contents?: true

Size: 1.41 KB

Versions: 41

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe Krikri::LDP::Resource do
  before do
    # a dummy resource
    class DummyResource; include Krikri::LDP::Resource; end
  end

  after do
    Object.send(:remove_const, 'DummyResource')
  end

  subject { DummyResource.new }

  it 'has a connection' do
    expect(subject.ldp_connection).to be_a Faraday::Connection
  end

  context 'with subject' do
    before do
      # add required interface to DummyResourcey
      class DummyResource
        def rdf_subject
          RDF::URI(Krikri::Settings['marmotta']['ldp']) / 'moomin-papa'
        end
      end
    end

    after do
      RDF::Marmotta.new(Krikri::Settings['marmotta']['base']).clear!
    end

    context 'with bad header' do
      it do
        error = Net::HTTPBadResponse.new("alue\" : \"1\"")
        expect_any_instance_of(Faraday::Adapter::NetHttp)
          .to receive(:perform_request).at_least(4).times.and_raise(error)
        expect { subject.get }.to raise_error
      end
    end

    context 'without marmotta connection' do
      before do
        @real_connection = Krikri::Settings['marmotta']['ldp']
        Krikri::Settings['marmotta']['ldp'] = 'http://localhost:4/marmotta/'
      end

      after do
        Krikri::Settings['marmotta']['ldp'] = @real_connection
      end

      it 'raises an appropriate error' do
        expect { subject.exists? }.to raise_error Faraday::ConnectionFailed
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
krikri-0.11.2 spec/ldp/resource_spec.rb
krikri-0.11.1 spec/ldp/resource_spec.rb
krikri-0.11.0 spec/ldp/resource_spec.rb
krikri-0.10.1 spec/ldp/resource_spec.rb
krikri-0.10.0 spec/ldp/resource_spec.rb
krikri-0.9.0 spec/ldp/resource_spec.rb
krikri-0.8.9 spec/ldp/resource_spec.rb
krikri-0.8.8 spec/ldp/resource_spec.rb
krikri-0.8.7 spec/ldp/resource_spec.rb
krikri-0.8.6 spec/ldp/resource_spec.rb
krikri-0.8.5 spec/ldp/resource_spec.rb
krikri-0.8.4 spec/ldp/resource_spec.rb
krikri-0.8.3 spec/ldp/resource_spec.rb
krikri-0.8.2 spec/ldp/resource_spec.rb
krikri-0.8.1 spec/ldp/resource_spec.rb
krikri-0.8.0 spec/ldp/resource_spec.rb
krikri-0.7.6 spec/ldp/resource_spec.rb
krikri-0.7.5 spec/ldp/resource_spec.rb
krikri-0.7.4 spec/ldp/resource_spec.rb
krikri-0.7.3 spec/ldp/resource_spec.rb