braque 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 931a1846f530b45eb05c1c6d11efe0b7ce663973
4
- data.tar.gz: 201d98bc6404e471c2385d3e62b9fd212334e805
3
+ metadata.gz: 2ab231c18ebc05e007531d66f7503b7b149213b6
4
+ data.tar.gz: d07db5d4abf55f5d8138dd73a904e672df2c064a
5
5
  SHA512:
6
- metadata.gz: 7eea7fbfd38cf6a0ff8f3d35429f2df7c88f8a91257a28fbbdc7c5c144d26b3d8ec003c0baeadee082918278e119e58b6a70879bce306624a0e16b7ede8d7a38
7
- data.tar.gz: 34dc5ac94b37da2ad6e755c91d594e090150caea2d764a6ddc6734e065f24e3d61c4dd2d47212450aab38d7d512942049645606f6da62e05aa717633bf7c895d
6
+ metadata.gz: 5f031712669fc5e2ed29f3a08e95744375d8f60a3608f50172eca74b121c830c68b7f860454080755f60de3df506d716615d4d359ca532f4bdbb038193d653bd
7
+ data.tar.gz: deb8befc3e96e1f3ae4d3358d0fb9053517a4217a7ce63f46a7dbc05784cacfd861f8ef400de548fb5e7d85eb808264a6bbd3ed824aea21d10b1815cf1a2dde0
data/lib/braque/model.rb CHANGED
@@ -32,7 +32,8 @@ module Braque
32
32
  cattr_accessor :api_token
33
33
 
34
34
  def list(options = {})
35
- response = client.method(collection_method_name).call(page: options[:page], size: options[:size])
35
+ options = Hash[options.map { |k, v| [CGI.escape(k.to_s), v] }]
36
+ response = client.method(collection_method_name).call(options)
36
37
  LinkedArray.new response, self
37
38
  end
38
39
 
@@ -1,3 +1,3 @@
1
1
  module Braque
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -34,30 +34,45 @@ RSpec.describe Braque::Model, type: :model do
34
34
  end
35
35
 
36
36
  context '.list' do
37
- before(:each) do
38
- root_request
39
- @collection_request = WebMock.stub_request(:get, "#{Breeze.api_root}/breezes")
40
- .with(headers: { 'Http-Authorization' => Breeze.api_token })
41
- .to_return(status: 200, body: collection_response)
42
- @breezes = Breeze.list
43
- end
44
- it 'performs the API root request' do
45
- expect(root_request).to have_been_requested
46
- end
47
- it 'performs the collection request' do
48
- expect(@collection_request).to have_been_requested
49
- end
50
- it 'returns an array of items' do
51
- expect(@breezes.count).to be 1
52
- expect(@breezes.first).to be_a_kind_of Breeze
53
- end
54
- it 'returns items with the correct class' do
55
- expect(@breezes.first).to be_a_kind_of Breeze
56
- end
57
- it 'returns an array of items with the correct attributes' do
58
- breeze = @breezes.first
59
- expect(breeze.id).to eq collection_response['_embedded']['breezes'].first['id']
60
- expect(breeze.title).to eq collection_response['_embedded']['breezes'].first['title']
37
+ context 'with results' do
38
+ before(:each) do
39
+ root_request
40
+ @collection_request = WebMock.stub_request(:get, "#{Breeze.api_root}/breezes")
41
+ .with(headers: { 'Http-Authorization' => Breeze.api_token })
42
+ .to_return(status: 200, body: collection_response)
43
+ @breezes = Breeze.list
44
+ end
45
+ it 'performs the API root request' do
46
+ expect(root_request).to have_been_requested
47
+ end
48
+ it 'performs the collection request' do
49
+ expect(@collection_request).to have_been_requested
50
+ end
51
+ it 'returns an array of items' do
52
+ expect(@breezes.count).to be 1
53
+ expect(@breezes.first).to be_a_kind_of Breeze
54
+ end
55
+ it 'returns items with the correct class' do
56
+ expect(@breezes.first).to be_a_kind_of Breeze
57
+ end
58
+ it 'returns an array of items with the correct attributes' do
59
+ breeze = @breezes.first
60
+ expect(breeze.id).to eq collection_response['_embedded']['breezes'].first['id']
61
+ expect(breeze.title).to eq collection_response['_embedded']['breezes'].first['title']
62
+ end
63
+ end
64
+ context 'with array params' do
65
+ before(:each) do
66
+ root_request
67
+ @collection_request = WebMock.stub_request(:get, "#{Breeze.api_root}/breezes")
68
+ .with(headers: { 'Http-Authorization' => Breeze.api_token })
69
+ .with(query: 'ids%5B0%5D=1&ids%5B1%5D=2')
70
+ .to_return(status: 200, body: collection_response)
71
+ @breezes = Breeze.list('ids[]' => [1, 2])
72
+ end
73
+ it 'performs the collection request with converted array params' do
74
+ expect(@collection_request).to have_been_requested
75
+ end
61
76
  end
62
77
  end
63
78
 
@@ -7,7 +7,7 @@
7
7
  "href":"http://localhost:9292/health"
8
8
  },
9
9
  "breezes":{
10
- "href":"http://localhost:9292/breezes{?page,size}",
10
+ "href":"http://localhost:9292/breezes{?page,size,ids%5B%5D*}",
11
11
  "templated":true
12
12
  },
13
13
  "breeze":{
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Fareed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-28 00:00:00.000000000 Z
11
+ date: 2015-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hyperclient
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  requirements: []
97
97
  rubyforge_project:
98
- rubygems_version: 2.2.2
98
+ rubygems_version: 2.4.3
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Braque provides a simple interface for interacting with Hypermedia API services