Skip to content

Commit fc9710e

Browse files
committed
Add check for default and user-specified User-Agent.
1 parent f8914d7 commit fc9710e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

lib/rdf/spec/http_adapter.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@
6363
end
6464
end
6565

66+
it "adds User-Agent header using default" do
67+
WebMock.stub_request(:get, uri).with do |request|
68+
expect(request.headers['User-Agent']).to eq "Ruby RDF.rb/#{RDF::VERSION}"
69+
end.to_return(body: "foo")
70+
RDF::Util::File.open_file(uri) do |f|
71+
opened.opened
72+
end
73+
end
74+
75+
it "used provided User-Agent header" do
76+
WebMock.stub_request(:get, uri).with do |request|
77+
expect(request.headers["User-Agent"]).to eq "Foo"
78+
end.to_return(body: "foo")
79+
RDF::Util::File.open_file(uri, headers: {"User-Agent" => "Foo"}) do |f|
80+
opened.opened
81+
end
82+
end
83+
6684
it "sets content_type and encoding to utf-8 if absent" do
6785
WebMock.stub_request(:get, uri).to_return(body: "foo", headers: {"Content-Type" => "text/turtle"})
6886
RDF::Util::File.open_file(uri) do |f|

0 commit comments

Comments
 (0)