test/response_test.rb in sawyer-0.0.7 vs test/response_test.rb in sawyer-0.0.8
- old
+ new
@@ -7,11 +7,14 @@
@stubs = Faraday::Adapter::Test::Stubs.new
@agent = Sawyer::Agent.new "http://foo.com" do |conn|
conn.builder.handlers.delete(Faraday::Adapter::NetHttp)
conn.adapter :test, @stubs do |stub|
stub.get '/' do
- [200, {'Content-Type' => 'application/json'}, Sawyer::Agent.encode(
+ [200, {
+ 'Content-Type' => 'application/json',
+ 'Link' => '</starred?page=2>; rel="next", </starred?page=19>; rel="last"'
+ }, Sawyer::Agent.encode(
:a => 1,
:_links => {
:self => {:href => '/a', :method => 'POST'}
}
)]
@@ -40,9 +43,13 @@
assert_equal 1, @res.data.a
assert_equal [:a], @res.data.fields.to_a
end
def test_gets_rels
+ assert_equal '/starred?page=2', @res.rels[:next].href
+ assert_equal :get, @res.rels[:next].method
+ assert_equal '/starred?page=19', @res.rels[:last].href
+ assert_equal :get, @res.rels[:next].method
assert_equal '/a', @res.data.rels[:self].href
assert_equal :post, @res.data.rels[:self].method
end
def test_gets_response_timing