restful_resource 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 319cf30c394b3307a02af91d62a46c977bda5e11
|
4
|
+
data.tar.gz: 339399b6d0252f5d75e94f186e72a07861ac056e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5282ec61b93e156b93572303b4f191a168c6893ef27525ce0413e7ca148a6199372fe05743db0ef941c8742a503d9b60864de8b718e4a7e61d2e8800816a0a11
|
7
|
+
data.tar.gz: 8118ff5f9df822f0af8b10ec900259914889d1c6f18142d2826828236fab5757af2468ba8d6b118235c76a0c3bf0a481085aa46e406678f688b75f4a80e70f63
|
@@ -8,5 +8,10 @@ module RestfulResource
|
|
8
8
|
response = RestClient.get(url, :accept => :json, authorization: @authorization)
|
9
9
|
Response.new(body: response.body, headers: response.headers, status: response.code)
|
10
10
|
end
|
11
|
+
|
12
|
+
def put(url, data: {})
|
13
|
+
response = RestClient.put(url, data, :accept => :json, authorization: @authorization)
|
14
|
+
Response.new(body: response.body, headers: response.headers, status: response.code)
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
@@ -107,7 +107,7 @@ describe RestfulResource::Base do
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
describe "#get" do
|
110
|
+
describe "#get" do
|
111
111
|
it "should return an open_object" do
|
112
112
|
expected_response = RestfulResource::Response.new(body: {average_score: 4.3}.to_json)
|
113
113
|
expect_get('http://api.carwow.co.uk/makes/average_score?make_slug%5B%5D=Volkswagen&make_slug%5B%5D=Audi', expected_response)
|
@@ -119,6 +119,17 @@ describe RestfulResource::Base do
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
+
describe "#put" do
|
123
|
+
it 'should put data properly' do
|
124
|
+
expected_response = RestfulResource::Response.new(body: nil, status: 200)
|
125
|
+
expect_put('http://api.carwow.co.uk/makes?make_slug=Volkswagen', expected_response)
|
126
|
+
|
127
|
+
Make.put(make_slug: 'Volkswagen')
|
128
|
+
|
129
|
+
expect(expected_response.status).to eq 200
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
122
133
|
describe ".as_json" do
|
123
134
|
before :each do
|
124
135
|
expected_response = RestfulResource::Response.new(body: [{name: 'Audi', slug: 'Audi-Slug'}, {name: 'Fiat', slug: 'Fiat-Slug'}].to_json)
|
@@ -1,13 +1,29 @@
|
|
1
1
|
require_relative '../spec_helper'
|
2
2
|
|
3
3
|
describe RestfulResource::HttpClient do
|
4
|
+
describe 'Basic HTTP' do
|
5
|
+
before :each do
|
6
|
+
@http_client = RestfulResource::HttpClient.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should execute get' do
|
10
|
+
response = @http_client.get('http://httpbin.org/get')
|
11
|
+
expect(response.status).to eq 200
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should execute put' do
|
15
|
+
response = @http_client.put('http://httpbin.org/put', data: { name: 'Alfred' })
|
16
|
+
expect(response.status).to eq 200
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
4
20
|
describe 'Authentication' do
|
5
21
|
before :each do
|
6
22
|
auth = RestfulResource::Authorization.http_authorization('user', 'passwd')
|
7
23
|
@http_client = RestfulResource::HttpClient.new(authorization: auth)
|
8
24
|
end
|
9
25
|
|
10
|
-
it 'should
|
26
|
+
it 'should execute authenticated get' do
|
11
27
|
response = @http_client.get('http://httpbin.org/basic-auth/user/passwd')
|
12
28
|
expect(response.status).to eq 200
|
13
29
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restful_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Santoro
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|