infrataster 0.2.4 → 0.2.5

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: 532ea3f659ce461a0d23d4bcfb89fece194a6f1a
4
- data.tar.gz: b42a4c93370ad95a98c20f3e8b12cc4e26b38de0
3
+ metadata.gz: 1ddec9ea2e17c599e93bde43dfcb46d4b4e3eec4
4
+ data.tar.gz: 542174438bfd08460623954456dabbd72a2d7c01
5
5
  SHA512:
6
- metadata.gz: c580b635be17a2fe0da95202737089defdf87fbb1fdd7860787fabb8f7f3dff31ba97ee2982acca4d363fc1799eb1535e373ecddfdf1780cd2e2aec5650f9c11
7
- data.tar.gz: 0d3efc0f9e89465c393d0467745868393c70de2c0ad895d46ba51c2768fcbb96636564449e8ad6a4b4883f44c1e560f4eae3694e5790ec997b43f89490157868
6
+ metadata.gz: ee75a9a51c1da1b37268399e2e444612d934d4f0858299a7b70cbadd5e8d8dc8edad7644a190ab7f343805e6ad91180750982949e6f5b17a3e49fb55ee31e2bb
7
+ data.tar.gz: 18323691afd689f840ca58b604edd14913dd25cf6668357dd36936d931f7298130c840926a847cf8f78a14286c42c7291bf2aabd0edf8d10acab0a24a9cd5bc5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Infrataster Changelog
2
2
 
3
+ ## v0.2.5
4
+
5
+ * [body option of http resource](https://github.com/ryotarai/infrataster/pull/57)
6
+
3
7
  ## v0.2.4
4
8
 
5
9
  * [Consider how to fetch the current example in RSpec v2.14.x (by @gongo)](https://github.com/ryotarai/infrataster/pull/56)
@@ -27,6 +27,9 @@ module Infrataster
27
27
  resource.headers.each_pair do |k, v|
28
28
  req.headers[k] = v
29
29
  end
30
+
31
+ req.body = resource.body if resource.body
32
+
30
33
  req.url resource.uri.path
31
34
  end
32
35
  end
@@ -41,6 +41,10 @@ module Infrataster
41
41
  @options[:headers]
42
42
  end
43
43
 
44
+ def body
45
+ @options[:body]
46
+ end
47
+
44
48
  def ssl_option
45
49
  @options[:ssl]
46
50
  end
@@ -1,3 +1,3 @@
1
1
  module Infrataster
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -65,6 +65,24 @@ describe server(:app) do
65
65
  end
66
66
  end
67
67
 
68
+ describe http('http://app.example.com', method: :post, body: {'foo' => 'bar'}, headers: {'USER' => 'VALUE'}) do
69
+ it "sends POST request with body entity" do
70
+ expect(body_as_json['method']).to eq('POST')
71
+ expect(body_as_json['body']).to eq("foo=bar")
72
+ expect(body_as_json['headers']['USER']).not_to be_empty
73
+ expect(body_as_json['headers']['USER']).to eq('VALUE')
74
+ end
75
+ end
76
+
77
+ describe http('http://app.example.com', method: :post, body: {'foo' => 'bar'}.to_json, headers: {'USER' => 'VALUE'}) do
78
+ it "sends POST request with body entity as JSON format" do
79
+ expect(body_as_json['method']).to eq('POST')
80
+ expect(body_as_json['body']).to eq({"foo" => "bar"}.to_json)
81
+ expect(body_as_json['headers']['USER']).not_to be_empty
82
+ expect(body_as_json['headers']['USER']).to eq('VALUE')
83
+ end
84
+ end
85
+
68
86
  describe http('/path/to/resource') do
69
87
  it "sends GET request with scheme and host" do
70
88
  expect(body_as_json['headers']['HOST']).to eq('example.com')
@@ -19,6 +19,7 @@ def result
19
19
  'method' => request.request_method,
20
20
  'path' => request.path_info,
21
21
  'params' => params,
22
+ 'body' => request.body.read,
22
23
  'headers' => RequestWrapper.new(request).headers,
23
24
  }
24
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infrataster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-19 00:00:00.000000000 Z
11
+ date: 2015-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec