spec/lib/ldp/response_spec.rb in ldp-0.0.3 vs spec/lib/ldp/response_spec.rb in ldp-0.0.4

- old
+ new

@@ -1,22 +1,21 @@ require 'spec_helper' describe Ldp::Response do LDP_RESOURCE_HEADERS = { "Link" => Ldp.resource.to_s + ";rel=\"type\""} - let(:mock_response) { double() } + let(:mock_response) { double(headers: {}, env: { url: "info:a" }) } let(:mock_client) { double(Ldp::Client) } subject do Ldp::Response.wrap mock_client, mock_response end describe ".wrap" do it "should mixin Ldp::Response into the raw response" do Ldp::Response.wrap(mock_client, mock_response) expect(mock_response).to be_a_kind_of(Ldp::Response) - expect(mock_response.ldp_client).to eq(mock_client) end end describe ".links" do it "should extract link headers with relations as a hash" do @@ -30,11 +29,11 @@ }) h = Ldp::Response.links mock_response expect(h['some-rel']).to include("xyz") expect(h['some-multi-rel']).to include("abc", "123") - expect(h['doesnt-exist']).to be_empty + expect(h['doesnt-exist']).to be_nil end it "should return an empty hash if no link headers are availabe" do mock_response.stub(:headers => {}) h = Ldp::Response.links mock_response @@ -56,11 +55,10 @@ end describe "#graph" do it "should parse the response body for an RDF graph" do mock_response.stub :body => "<> <info:b> <info:c> .", :headers => LDP_RESOURCE_HEADERS - subject.stub :page_subject => RDF::URI.new('info:a') graph = subject.graph expect(graph).to have_subject(RDF::URI.new("info:a")) expect(graph).to have_statement RDF::Statement.new(RDF::URI.new("info:a"), RDF::URI.new("info:b"), RDF::URI.new("info:c")) @@ -84,12 +82,10 @@ describe "#has_page" do it "should see if the response has an ldp:Page statement" do graph = RDF::Graph.new - subject.stub :page_subject => RDF::URI.new('info:a') - graph << [RDF::URI.new('info:a'), RDF.type, Ldp.page] mock_response.stub :body => graph.dump(:ttl), :headers => LDP_RESOURCE_HEADERS expect(subject).to have_page @@ -103,11 +99,9 @@ end describe "#page" do it "should get the ldp:Page data from the query" do graph = RDF::Graph.new - - subject.stub :page_subject => RDF::URI.new('info:a') graph << [RDF::URI.new('info:a'), RDF.type, Ldp.page] graph << [RDF::URI.new('info:b'), RDF.type, Ldp.page] mock_response.stub :body => graph.dump(:ttl), :headers => LDP_RESOURCE_HEADERS