service_api 0.0.4 → 0.0.5
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 +4 -4
- data/lib/service_api/base_faraday.rb +7 -8
- data/lib/service_api/version.rb +1 -1
- data/spec/functionals/base_faraday_spec.rb +10 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ed0b2e5f4d98f84bf309258e33da930bebfcab9
|
4
|
+
data.tar.gz: c3af2e6e274483ee78cd39be88c749990bdc2397
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14e1ad28f4f1f4d7ef719787de7f1885a15c29c97aa79263378758ad8e97dc5641db1fa935305ab99f627cb4e31590c047d50867ea5ae44a3d03fab1b92464c7
|
7
|
+
data.tar.gz: f092e6bfbbd19fa3962774a3db738e24d5dab93a8515aa5836bf8de22d37c57f35b9bf5c0772c8add90870f164ab1313c1ee3beecf17e00a3434634309063e0e
|
@@ -17,13 +17,12 @@ module ServiceApi
|
|
17
17
|
# end
|
18
18
|
#
|
19
19
|
module BaseFaraday
|
20
|
-
|
21
|
-
# Initilizer require client class as parameter
|
20
|
+
# Initilizer require config hash as parameter
|
22
21
|
#
|
23
|
-
# MyApi.new(
|
22
|
+
# MyApi.new(config)
|
24
23
|
#
|
25
|
-
def initialize(
|
26
|
-
@
|
24
|
+
def initialize(config)
|
25
|
+
@config = config
|
27
26
|
@params = {}
|
28
27
|
end
|
29
28
|
|
@@ -73,10 +72,10 @@ module ServiceApi
|
|
73
72
|
builder.response :xml, content_type: /\bxml$/
|
74
73
|
builder.response :json, content_type: /\bjson$/
|
75
74
|
|
76
|
-
if @
|
77
|
-
builder.adapter @
|
75
|
+
if @config[:adapter] == :test
|
76
|
+
builder.adapter @config[:adapter], @config[:adapter_options]
|
78
77
|
else
|
79
|
-
builder.adapter @
|
78
|
+
builder.adapter @config[:adapter]
|
80
79
|
end
|
81
80
|
end
|
82
81
|
end
|
data/lib/service_api/version.rb
CHANGED
@@ -1,17 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class Client
|
4
|
-
def options
|
5
|
-
{ adapter: :test, adapter_options: faraday_stubs }
|
6
|
-
end
|
7
|
-
|
8
|
-
def faraday_stubs
|
9
|
-
Faraday::Adapter::Test::Stubs.new do |stub|
|
10
|
-
stub.get('/test/request?api_key=abcd&sample=true') { [200, {}, 'OK'] }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
3
|
class MyApi
|
16
4
|
include ServiceApi::BaseFaraday
|
17
5
|
|
@@ -47,9 +35,16 @@ class Sample2Api < MyApi
|
|
47
35
|
end
|
48
36
|
|
49
37
|
describe ServiceApi::BaseFaraday do
|
50
|
-
let(:
|
51
|
-
|
52
|
-
|
38
|
+
let(:config) do
|
39
|
+
{
|
40
|
+
adapter: :test,
|
41
|
+
adapter_options: Faraday::Adapter::Test::Stubs.new do |stub|
|
42
|
+
stub.get('/test/request?api_key=abcd&sample=true') { [200, {}, 'OK'] }
|
43
|
+
end
|
44
|
+
}
|
45
|
+
end
|
46
|
+
let(:model) { SampleApi.new(config) }
|
47
|
+
let(:model2) { Sample2Api.new(config) }
|
53
48
|
|
54
49
|
describe 'model' do
|
55
50
|
it 'should return string' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Wawer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|