Sha256: 24ac1e4011a9a73d936fdfd46dc4126d09d3029aee5b18b2769d5320c36cec0f

Contents?: true

Size: 1.62 KB

Versions: 21

Compression:

Stored size: 1.62 KB

Contents

require 'rest-core/test'

describe RC::ParseLink do
  describe 'http://tools.ietf.org/html/rfc5988' do
    would '5.5 a' do
      link = '<http://example.com/TheBook/chapter2>; rel="previous"; title="previous chapter"'
      RC::ParseLink.parse_link(link).should.eq(
        'previous' => {'uri' => 'http://example.com/TheBook/chapter2',
                       'rel' => 'previous',
                       'title' => 'previous chapter'})
    end

    would '5.5 b' do
      link = '</>; rel="http://example.net/foo"'
      RC::ParseLink.parse_link(link).should.eq(
        'http://example.net/foo' => {'uri' => '/',
                                     'rel' => 'http://example.net/foo'})
    end

    would '5.5 c (we did not implement * and unescape for now)' do
      link = <<-LINK
</TheBook/chapter2>; rel="previous"; title*=UTF-8'de'letztes%20Kapitel, </TheBook/chapter4>; rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel
      LINK
      RC::ParseLink.parse_link(link).should.eq(
        'previous' => {'uri' => '/TheBook/chapter2',
                       'rel' => 'previous',
                       'title*' => "UTF-8'de'letztes%20Kapitel"},
        'next'     => {'uri' => '/TheBook/chapter4',
                       'rel' => 'next',
                       'title*' => "UTF-8'de'n%c3%a4chstes%20Kapitel"})
    end

    would '5.5 d' do
      link = '<http://example.org/>; rel="start http://example.net/relation/other"'

      RC::ParseLink.parse_link(link).should.eq(
        'start http://example.net/relation/other' =>
          {'uri' => 'http://example.org/',
           'rel' => 'start http://example.net/relation/other'})
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rest-core-3.3.0 test/test_parse_link.rb