pmp 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,40 +48,58 @@ describe PMP::Link do
48
48
  end
49
49
 
50
50
  it "can get a link for templated href" do
51
- l = {
52
- "hints" => {
53
- "allow" => [
54
- "GET"
55
- ]
56
- },
57
- "href-template" => "https://api-sandbox.pmp.io/docs{?limit,offset,tag,collection,text,searchsort,has,author,distributor,distributorgroup,startdate,enddate,profile,language}",
58
- "href-vars" => {
59
- "author" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
60
- "collection" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
61
- "distributor" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
62
- "distributorgroup" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
63
- "enddate" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
64
- "has" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
65
- "language" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
66
- "limit" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
67
- "offset" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
68
- "profile" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
69
- "searchsort" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
70
- "startdate" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
71
- "tag" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
72
- "text" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval"
73
- },
74
- "rels" => [
75
- "urn:pmp:query:docs"
76
- ],
77
- "title" => "Query for documents"
78
- }
79
-
80
- @link = PMP::Link.new(@parent, l)
81
- @link.hints.must_equal l['hints']
51
+ @link = PMP::Link.new(@parent, query_document_info)
52
+ @link.hints.must_equal query_document_info['hints']
82
53
  @link.url.must_equal "https://api-sandbox.pmp.io/docs"
83
54
  @link.where('limit' => 10).url.must_equal "https://api-sandbox.pmp.io/docs?limit=10"
84
55
  @link.url.must_equal "https://api-sandbox.pmp.io/docs"
85
56
  end
86
57
 
58
+ it "follows a link to get underlying resource" do
59
+
60
+ link_doc = json_file(:collection_query)
61
+
62
+ stub_request(:get, "https://api-sandbox.pmp.io/docs?limit=10&tag=test").
63
+ with(:headers => {'Accept'=>'application/vnd.pmp.collection.doc+json', 'Content-Type'=>'application/vnd.pmp.collection.doc+json', 'Host'=>'api-sandbox.pmp.io:443'}).
64
+ to_return(:status => 200, :body => link_doc, :headers => {})
65
+
66
+ @link = PMP::Link.new(nil, query_document_info)
67
+ docs = @link.where(limit: 10, tag: 'test')
68
+ docs.must_be_instance_of PMP::Link
69
+ guids = docs.items.collect(&:guid).sort
70
+ guids.first.must_equal "03796e02-48f4-40aa-b457-2ffeba3d8d39"
71
+ guids.last.must_equal "e30690e1-3f20-408a-9dba-94172caf49c7"
72
+ end
73
+
74
+ def query_document_info
75
+ {
76
+ "hints" => {
77
+ "allow" => [
78
+ "GET"
79
+ ]
80
+ },
81
+ "href-template" => "https://api-sandbox.pmp.io/docs{?limit,offset,tag,collection,text,searchsort,has,author,distributor,distributorgroup,startdate,enddate,profile,language}",
82
+ "href-vars" => {
83
+ "author" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
84
+ "collection" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
85
+ "distributor" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
86
+ "distributorgroup" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
87
+ "enddate" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
88
+ "has" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
89
+ "language" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
90
+ "limit" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
91
+ "offset" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
92
+ "profile" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
93
+ "searchsort" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
94
+ "startdate" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
95
+ "tag" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval",
96
+ "text" => "https://github.com/publicmediaplatform/pmpdocs/wiki/Content-Retrieval"
97
+ },
98
+ "rels" => [
99
+ "urn:pmp:query:docs"
100
+ ],
101
+ "title" => "Query for documents"
102
+ }
103
+ end
104
+
87
105
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kuklewicz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: minitest
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -285,6 +271,7 @@ extra_rdoc_files: []
285
271
  files:
286
272
  - .gitignore
287
273
  - .ruby-version
274
+ - .travis.yml
288
275
  - Gemfile
289
276
  - Guardfile
290
277
  - LICENSE.txt