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 +4 -4
- data/lib/braque/model.rb +2 -1
- data/lib/braque/version.rb +1 -1
- data/spec/braque/model_spec.rb +39 -24
- data/spec/fixtures/root.json +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ab231c18ebc05e007531d66f7503b7b149213b6
|
4
|
+
data.tar.gz: d07db5d4abf55f5d8138dd73a904e672df2c064a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|
data/lib/braque/version.rb
CHANGED
data/spec/braque/model_spec.rb
CHANGED
@@ -34,30 +34,45 @@ RSpec.describe Braque::Model, type: :model do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
context '.list' do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
|
data/spec/fixtures/root.json
CHANGED
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.
|
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-
|
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.
|
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
|