rddd 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -4
- data/Gemfile.lock +2 -9
- data/lib/rddd/services/transports/http_json.rb +8 -3
- data/lib/rddd/version.rb +1 -1
- data/spec/lib/services/transports/http_json_spec.rb +9 -9
- metadata +1 -1
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,8 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rddd (0.2.4)
|
5
|
-
curb
|
6
|
-
|
7
1
|
GEM
|
8
2
|
remote: https://rubygems.org/
|
9
3
|
specs:
|
10
|
-
curb (0.8.3)
|
11
4
|
diff-lcs (1.1.3)
|
5
|
+
httpclient (2.3.2)
|
12
6
|
metaclass (0.0.1)
|
13
7
|
mocha (0.13.1)
|
14
8
|
metaclass (~> 0.0.1)
|
@@ -26,8 +20,7 @@ PLATFORMS
|
|
26
20
|
ruby
|
27
21
|
|
28
22
|
DEPENDENCIES
|
29
|
-
|
23
|
+
httpclient
|
30
24
|
mocha
|
31
25
|
rake
|
32
|
-
rddd!
|
33
26
|
rspec
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'httpclient'
|
2
|
+
|
1
3
|
module Rddd
|
2
4
|
module Services
|
3
5
|
module Transports
|
@@ -7,9 +9,12 @@ module Rddd
|
|
7
9
|
end
|
8
10
|
|
9
11
|
def call(service_name, attributes)
|
10
|
-
JSON.parse(
|
11
|
-
|
12
|
-
|
12
|
+
JSON.parse(
|
13
|
+
HTTPClient.new.post("#{@endpoint}#{service_name}",
|
14
|
+
:body => JSON.unparse(attributes),
|
15
|
+
:header => {'Content-Type' => 'application/json'}
|
16
|
+
).body
|
17
|
+
)
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
data/lib/rddd/version.rb
CHANGED
@@ -20,21 +20,21 @@ module Rddd
|
|
20
20
|
|
21
21
|
let(:attributes) { {'foo' => 'bar'} }
|
22
22
|
|
23
|
-
let(:
|
23
|
+
let(:body) { {'foo' => 'bar'} }
|
24
24
|
|
25
|
-
let(:
|
25
|
+
let(:client) { stub('client') }
|
26
26
|
|
27
|
-
|
28
|
-
Curl.expects(:post) \
|
29
|
-
.with('http://remote.dev/service_name', JSON.unparse(attributes)) \
|
30
|
-
.yields(curl) \
|
31
|
-
.returns(curl)
|
27
|
+
let(:result) { stub('result', :body => JSON.unparse(body)) }
|
32
28
|
|
33
|
-
|
29
|
+
before do
|
30
|
+
HTTPClient.expects(:new).returns(client)
|
31
|
+
client.expects(:post) \
|
32
|
+
.with('http://remote.dev/service_name', :body => JSON.unparse(attributes), :header => {'Content-Type' => 'application/json'}) \
|
33
|
+
.returns(result)
|
34
34
|
end
|
35
35
|
|
36
36
|
|
37
|
-
it { should ==
|
37
|
+
it { should == body }
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|