Skip to content

Commit 5ea6f0e

Browse files
committed
Fix content-type expectations, as text/plain no longer is the same as N-Triples.
1 parent d4b44c0 commit 5ea6f0e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

spec/client_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def response(header)
5858

5959
it "handles successful response with plain header" do
6060
expect(subject).to receive(:request).and_yield response('text/plain')
61-
expect(RDF::Reader).to receive(:for).with(content_type: 'text/plain').and_call_original
62-
subject.query(query)
61+
expect(RDF::Reader).to receive(:for).with(content_type: 'application/n-triples').and_call_original
62+
subject.query(query, content_type: 'application/n-triples')
6363
end
6464

6565
it "handles successful response with boolean header" do
@@ -109,17 +109,17 @@ def response(header)
109109
end
110110

111111
it "handles successful response with custom headers" do
112-
expect(subject).to receive(:request).with(anything, {"Authorization" => "Basic XXX=="}).
113-
and_yield response('text/plain')
114-
subject.query(query, headers: {"Authorization" => "Basic XXX=="})
112+
expect(subject).to receive(:request).with(anything, {"Authorization" => "Basic XXX==", "Content-Type" => "application/n-triples"}).
113+
and_yield response('application/n-triples')
114+
subject.query(query, headers: {"Authorization" => "Basic XXX==", "Content-Type" => "application/n-triples"})
115115
end
116116

117117
it "handles successful response with initial custom headers" do
118118
options = {headers: {"Authorization" => "Basic XXX=="}, method: :get}
119119
client = SPARQL::Client.new('http://data.linkedmdb.org/sparql', **options)
120-
client.instance_variable_set :@http, double(request: response('text/plain'))
120+
client.instance_variable_set :@http, double(request: response('application/n-triples'))
121121
expect(Net::HTTP::Get).to receive(:new).with(anything, hash_including(options[:headers]))
122-
client.query(query)
122+
client.query(query, content_type: 'application/n-triples')
123123
end
124124

125125
it "enables overriding the http method" do
@@ -194,15 +194,15 @@ def response(header)
194194
to_return(body: '', status: 200, headers: { 'Content-Type' => 'application/n-triples'})
195195
subject.query(construct_query)
196196
expect(WebMock).to have_requested(:post, "http://data.linkedmdb.org/sparql").
197-
with(headers: {'Accept'=>'application/n-triples, text/plain, */*;q=0.1'})
197+
with(headers: {'Accept'=>'application/n-triples, */*;q=0.1'})
198198
end
199199

200200
it "uses application/n-triples for DESCRIBE" do
201201
WebMock.stub_request(:any, 'http://data.linkedmdb.org/sparql').
202202
to_return(body: '', status: 200, headers: { 'Content-Type' => 'application/n-triples'})
203203
subject.query(describe_query)
204204
expect(WebMock).to have_requested(:post, "http://data.linkedmdb.org/sparql").
205-
with(headers: {'Accept'=>'application/n-triples, text/plain, */*;q=0.1'})
205+
with(headers: {'Accept'=>'application/n-triples, */*;q=0.1'})
206206
end
207207

208208
it "uses application/sparql-results+json for SELECT" do

0 commit comments

Comments
 (0)