api-model 2.1.1 → 2.2.0

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: f8273b2a0168dac33ede420787115f8cf034fedd
4
- data.tar.gz: d4353c56c88b74051a74ab7d6dbb6385cd4e9e8a
3
+ metadata.gz: d8d62657906fcf3a59d70190108320e85a72688d
4
+ data.tar.gz: c1cab41f5a240bcfc5146b088ed61f184bb87367
5
5
  SHA512:
6
- metadata.gz: dd797e47911ad4b432e3bf0c6da1a0ba456cd46891a1e935dd8598f97146c90bf74ac485eb13fe66641bddfc2c5be868c0a95f9d2a6b97a49872c422b9421f09
7
- data.tar.gz: 2a0b2cab17ead05483a17b12f58b07a5609877cb82a1ffade8e05020c2d33afb4b4f6af0d7c1d2aaf6f72f0a33d5e8018dfeee7c41e0f9369f67aa5c3c223409
6
+ metadata.gz: 7ebe46b16b9585b10ab7becfd72444e3cd4ff4a936e7b1a35bc179b54421b00d9d72dfb60cbb792285a454aa31f7c5e143e2f7309ac25d70765c0bc08fc73b34
7
+ data.tar.gz: 33f1b1abf718a509d04e28a1ce13b770697206a670bcdfedad3ca632b6357cf4a646726c869e2bd48a176ff0c381fb31ac0b2402b623477461f0318efdd77a13
@@ -1,20 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api-model (2.1.1)
4
+ api-model (2.2.0)
5
5
  activemodel (~> 4.1)
6
6
  activesupport (~> 4.1)
7
7
  hash-pipe (~> 0.0)
8
+ http-cookie (~> 1.0)
8
9
  typhoeus (~> 0.6)
9
10
  virtus (~> 1.0)
10
11
 
11
12
  GEM
12
13
  remote: https://rubygems.org/
13
14
  specs:
14
- activemodel (4.1.1)
15
- activesupport (= 4.1.1)
15
+ activemodel (4.1.5)
16
+ activesupport (= 4.1.5)
16
17
  builder (~> 3.1)
17
- activesupport (4.1.1)
18
+ activesupport (4.1.5)
18
19
  i18n (~> 0.6, >= 0.6.9)
19
20
  json (~> 1.7, >= 1.7.7)
20
21
  minitest (~> 5.1)
@@ -34,17 +35,21 @@ GEM
34
35
  descendants_tracker (0.0.4)
35
36
  thread_safe (~> 0.3, >= 0.3.1)
36
37
  diff-lcs (1.2.5)
38
+ domain_name (0.5.20)
39
+ unf (>= 0.0.5, < 1.0.0)
37
40
  equalizer (0.0.9)
38
- ethon (0.7.0)
41
+ ethon (0.7.1)
39
42
  ffi (>= 1.3.0)
40
43
  ffi (1.9.3)
41
44
  hash-pipe (0.0.2)
42
45
  activesupport (~> 4.1)
43
- i18n (0.6.9)
46
+ http-cookie (1.0.2)
47
+ domain_name (~> 0.5)
48
+ i18n (0.6.11)
44
49
  ice_nine (0.11.0)
45
50
  json (1.8.1)
46
51
  method_source (0.8.2)
47
- minitest (5.3.3)
52
+ minitest (5.4.0)
48
53
  pry (0.9.12.2)
49
54
  coderay (~> 1.0.5)
50
55
  method_source (~> 0.8)
@@ -59,17 +64,20 @@ GEM
59
64
  rspec-mocks (2.14.4)
60
65
  safe_yaml (0.9.7)
61
66
  slop (3.4.6)
62
- thread_safe (0.3.3)
63
- typhoeus (0.6.8)
64
- ethon (>= 0.7.0)
65
- tzinfo (1.1.0)
67
+ thread_safe (0.3.4)
68
+ typhoeus (0.6.9)
69
+ ethon (>= 0.7.1)
70
+ tzinfo (1.2.2)
66
71
  thread_safe (~> 0.1)
72
+ unf (0.1.4)
73
+ unf_ext
74
+ unf_ext (0.0.6)
67
75
  vcr (2.8.0)
68
- virtus (1.0.2)
76
+ virtus (1.0.3)
69
77
  axiom-types (~> 0.1)
70
78
  coercible (~> 1.0)
71
- descendants_tracker (~> 0.0.3)
72
- equalizer (~> 0.0.9)
79
+ descendants_tracker (~> 0.0, >= 0.0.3)
80
+ equalizer (~> 0.0, >= 0.0.9)
73
81
  webmock (1.15.0)
74
82
  addressable (>= 2.2.7)
75
83
  crack (>= 0.3.2)
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "api-model"
5
- s.version = "2.1.1"
5
+ s.version = "2.2.0"
6
6
  s.authors = ["Damien Timewell", "Erik Rothoff Andersson"]
7
7
  s.email = ["mail@damientimewell.com", "erik.rothoff@gmail.com"]
8
8
  s.licenses = ['MIT']
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency 'typhoeus', '~> 0.6'
16
16
  s.add_dependency 'virtus', '~> 1.0'
17
17
  s.add_dependency 'hash-pipe', '~> 0.0'
18
+ s.add_dependency 'http-cookie', '~> 1.0'
18
19
 
19
20
  s.add_development_dependency "rspec", '~> 2.14'
20
21
  s.add_development_dependency "pry", '~> 0.9'
@@ -6,6 +6,7 @@ require 'virtus'
6
6
  require 'typhoeus'
7
7
  require 'ostruct'
8
8
  require 'hash-pipe'
9
+ require 'http-cookie'
9
10
 
10
11
  require 'api_model/assignment'
11
12
  require 'api_model/initializer'
@@ -49,6 +49,16 @@ module ApiModel
49
49
  http_response.api_call.success?
50
50
  end
51
51
 
52
+ def response_cookies
53
+ jar = HTTP::CookieJar.new
54
+
55
+ http_response.api_call.headers_hash["Set-Cookie"].split(", ").each do |cookie|
56
+ jar.parse cookie, http_response.api_call.request.base_url
57
+ end
58
+
59
+ jar.cookies
60
+ end
61
+
52
62
  # Define common methods which should never be called on this abstract class, and should always be
53
63
  # passed down to the #objects
54
64
  FALL_THROUGH_METHODS.each do |transparent_method|
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'support/mock_models/blog_post'
3
3
  require 'support/mock_models/user'
4
+ require 'support/mock_models/banana'
4
5
 
5
6
  describe ApiModel::Response do
6
7
 
@@ -193,4 +194,21 @@ describe ApiModel::Response do
193
194
  end
194
195
  end
195
196
 
197
+ describe "Cookies" do
198
+ let(:cookie_response) do
199
+ VCR.use_cassette('cookies') do
200
+ ApiModel::HttpRequest.new(path: "http://api-model-specs.com/cookie", method: :get, builder: Banana).run
201
+ end
202
+ end
203
+
204
+ describe "fetching Set-Cookie headers" do
205
+ it 'should return an array of cookies' do
206
+ cookie_response.response_cookies.should be_a(Array)
207
+ cookie_response.response_cookies.map do |cookie|
208
+ cookie.should be_a(HTTP::Cookie)
209
+ end
210
+ end
211
+ end
212
+ end
213
+
196
214
  end
@@ -0,0 +1,30 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api-model-specs.com/cookie
6
+ headers:
7
+ User-Agent:
8
+ - Typhoeus - https://github.com/typhoeus/typhoeus
9
+ response:
10
+ status:
11
+ code: 200
12
+ message: OK
13
+ headers:
14
+ Server:
15
+ - nginx/1.4.1
16
+ Date:
17
+ - Thu, 28 Nov 2013 16:02:56 GMT
18
+ Content-Type:
19
+ - text/plain; charset=utf-8
20
+ Content-Length:
21
+ - '248'
22
+ Connection:
23
+ - keep-alive
24
+ Set-Cookie:
25
+ - SESSION_ID=abc123; Path=/foo; HttpOnly, foo=bar; Path=/bar; HttpOnly
26
+ body:
27
+ encoding: UTF-8
28
+ string: "{}"
29
+ http_version:
30
+ recorded_at: Thu, 28 Nov 2013 16:02:20 GMT
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Timewell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-12 00:00:00.000000000 Z
12
+ date: 2014-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: http-cookie
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1.0'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.0'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: rspec
86
100
  requirement: !ruby/object:Gem::Requirement
@@ -173,6 +187,7 @@ files:
173
187
  - spec/api-model/response_spec.rb
174
188
  - spec/spec_helper.rb
175
189
  - spec/support/fixtures/cars.yml
190
+ - spec/support/fixtures/cookies.yml
176
191
  - spec/support/fixtures/errors.yml
177
192
  - spec/support/fixtures/posts.yml
178
193
  - spec/support/fixtures/users.yml
@@ -214,6 +229,7 @@ test_files:
214
229
  - spec/api-model/response_spec.rb
215
230
  - spec/spec_helper.rb
216
231
  - spec/support/fixtures/cars.yml
232
+ - spec/support/fixtures/cookies.yml
217
233
  - spec/support/fixtures/errors.yml
218
234
  - spec/support/fixtures/posts.yml
219
235
  - spec/support/fixtures/users.yml