siren_client 2.0.0 → 2.0.1

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: 64e224e64dc04f3274a0bf852c0db04ea38ef36d
4
- data.tar.gz: b9a44d4d0d8c04fda5d9abe932516afb00b71a71
3
+ metadata.gz: 6a253bc2fd4e72e714faf829cc0f271d13b4f5ba
4
+ data.tar.gz: f6b6070713bcccca1cb21d82e779f10721059d7c
5
5
  SHA512:
6
- metadata.gz: a55f189f389e87f9f6bd03e6146140a876cacb753915dd86e7ccc021dcd26c61beb4068fcb6b6ba931a952c770bd2ce11851b83708d0ead04086bb724ba60823
7
- data.tar.gz: d2593af969d9d4b5ef024055b1cd19a7c309d05d8ed52cfda2890b7724c2cf80dfa5e4aa7f3a53852702a674ba41dda0b2d75b951a6fad84e90da135783780e6
6
+ metadata.gz: 332a452ba08d4dfe61c9d72c50c8ebf5ebc116cc9028699d01848ee0b05609b368fd0d4889f7143437f7c991b008aaa18aeba5da76a0f37782f0d7decbae4e84
7
+ data.tar.gz: '092c322d52c5f28f07dffd66ea1ede17fc442ac7ea22c2ab45f36c0d2379ada853e398ce0919c135817abdf795dde03c809c8ef8bdf6026d5854c16e2a3dc772'
@@ -26,13 +26,16 @@ module SirenClient
26
26
  end
27
27
 
28
28
  def where(params = {})
29
- options = { headers: {}, query: {}, body: {} }.merge @config
29
+ options = { headers: {} }.merge @config
30
30
  if @method == 'get'
31
31
  options[:query] = params
32
32
  else
33
33
  options[:body] = params
34
+
35
+ # Only set the Content-Type if we have a body
36
+ options[:headers]['Content-Type'] = @type
34
37
  end
35
- options[:headers]['Content-Type'] = @type
38
+
36
39
  begin
37
40
  resp = generate_raw_response(@method, self.href, options)
38
41
  if next_response_is_raw?
@@ -1,3 +1,3 @@
1
1
  module SirenClient
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -14,16 +14,24 @@ describe SirenClient::Action do
14
14
  end
15
15
  end
16
16
 
17
+ let (:output_buffer) {
18
+ StringIO.new
19
+ }
17
20
  let (:action) {
18
21
  SirenClient::Action.new(action_data, {
19
- headers: { "Accept" => "application/json" }
22
+ headers: { "Accept" => "application/json" },
23
+ debug_output: output_buffer
20
24
  })
21
25
  }
22
26
  let (:action_post) {
23
- SirenClient::Action.new(action_data_post)
27
+ SirenClient::Action.new(action_data_post, {
28
+ debug_output: output_buffer
29
+ })
24
30
  }
25
31
  let (:action_delete) {
26
- SirenClient::Action.new(action_data_delete)
32
+ SirenClient::Action.new(action_data_delete, {
33
+ debug_output: output_buffer
34
+ })
27
35
  }
28
36
  describe '.config' do
29
37
  it 'is a hash' do
@@ -96,10 +104,18 @@ describe SirenClient::Action do
96
104
  # I'm expecting an error here, all I want to see is that the url it being traversed.
97
105
  expect { action.where(test: 'hi') }.to raise_error SirenClient::InvalidResponseError
98
106
  end
107
+ it 'GET action does not send the Content-Type header' do
108
+ expect { action.where(test: 'hi') }.to raise_error SirenClient::InvalidResponseError
109
+ expect(output_buffer.string).not_to include('Content-Type: application/x-www-form-urlencoded')
110
+ end
99
111
  it 'executes the POST action' do
100
112
  # I'm expecting an error here, all I want to see is that the url it being traversed.
101
113
  expect { action_post.where(test: 'hi') }.to raise_error SirenClient::InvalidResponseError
102
114
  end
115
+ it 'POST action does send the Content-Type header' do
116
+ expect { action_post.where(test: 'hi') }.to raise_error SirenClient::InvalidResponseError
117
+ expect(output_buffer.string).to include('Content-Type: application/x-www-form-urlencoded')
118
+ end
103
119
  it 'executes the DELETE action' do
104
120
  expect { action_delete.submit }.to raise_error SirenClient::InvalidResponseError
105
121
  end
@@ -127,7 +127,7 @@ describe SirenClient::Entity do
127
127
  expect(entity.go).to eq(nil)
128
128
  end
129
129
  it 'initiate a request if it IS an entity sub-link' do
130
- expect { graph.entities[0].go }.to raise_error Errno::ECONNREFUSED
130
+ expect { graph.entities[0].go }.to raise_error SystemCallError
131
131
  end
132
132
  end
133
133
  describe '.invalidkey' do
@@ -145,10 +145,10 @@ describe SirenClient::Entity do
145
145
  describe '.validkey' do
146
146
  let (:graph) { entity[0] }
147
147
  it 'can access an entity sub-link within the entity' do
148
- expect { graph.messages }.to raise_error Errno::ECONNREFUSED
148
+ expect { graph.messages }.to raise_error SystemCallError
149
149
  end
150
150
  it 'can access a link directly on the entity' do
151
- expect { entity.next }.to raise_error Errno::ECONNREFUSED
151
+ expect { entity.next }.to raise_error SystemCallError
152
152
  end
153
153
  it 'can access an action directly on the entity' do
154
154
  expect(entity.filter_concepts).to be_a SirenClient::Action
@@ -226,14 +226,14 @@ describe SirenClient::Entity do
226
226
  describe 'underscore support' do
227
227
  it 'can access entity sub-links' do
228
228
  # Since this will trigger the sub-link. We expect an error
229
- expect { graph.user_preferences }.to raise_error Errno::ECONNREFUSED
229
+ expect { graph.user_preferences }.to raise_error SystemCallError
230
230
  end
231
231
  it 'can access actions' do
232
232
  expect(entity.filter_messages).to be_a SirenClient::Action
233
233
  end
234
234
  it 'can access links' do
235
235
  # Since this will trigger the link. We expect an error
236
- expect { entity.prev_page }.to raise_error Errno::ECONNREFUSED
236
+ expect { entity.prev_page }.to raise_error SystemCallError
237
237
  end
238
238
  end
239
239
  describe '.with_raw_response' do
@@ -246,7 +246,7 @@ describe SirenClient::Entity do
246
246
  end
247
247
  it 'should still allow a network request to be made' do
248
248
  entity.with_raw_response
249
- expect { entity.with_raw_response.prev_page }.to raise_error Errno::ECONNREFUSED
249
+ expect { entity.with_raw_response.prev_page }.to raise_error SystemCallError
250
250
  end
251
251
  end
252
252
  # Entities enumerable support
metadata CHANGED
@@ -1,150 +1,164 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siren_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chason Choate
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-22 00:00:00.000000000 Z
11
+ date: 2017-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: httparty
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
19
  version: '0.13'
19
- name: httparty
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: activesupport
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '4'
33
- name: activesupport
34
- prerelease: false
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4'
41
41
  - !ruby/object:Gem::Dependency
42
+ name: bundler
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - ">="
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
47
- name: bundler
48
- prerelease: false
49
48
  type: :development
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
+ name: rack
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - "~>"
59
60
  - !ruby/object:Gem::Version
60
61
  version: '1.5'
61
- name: rack
62
- prerelease: false
63
62
  type: :development
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.5'
69
69
  - !ruby/object:Gem::Dependency
70
+ name: rake
70
71
  requirement: !ruby/object:Gem::Requirement
71
72
  requirements:
72
73
  - - ">="
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
- name: rake
76
- prerelease: false
77
76
  type: :development
77
+ prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
+ name: sinatra
84
85
  requirement: !ruby/object:Gem::Requirement
85
86
  requirements:
86
87
  - - ">="
87
88
  - !ruby/object:Gem::Version
88
89
  version: '0'
89
- name: sinatra
90
- prerelease: false
91
90
  type: :development
91
+ prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
+ name: rspec
98
99
  requirement: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - ">="
101
102
  - !ruby/object:Gem::Version
102
103
  version: '0'
103
- name: rspec
104
- prerelease: false
105
104
  type: :development
105
+ prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
+ name: guard
112
113
  requirement: !ruby/object:Gem::Requirement
113
114
  requirements:
114
115
  - - ">="
115
116
  - !ruby/object:Gem::Version
116
117
  version: '0'
117
- name: guard
118
- prerelease: false
119
118
  type: :development
119
+ prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
+ name: guard-rspec
126
127
  requirement: !ruby/object:Gem::Requirement
127
128
  requirements:
128
129
  - - ">="
129
130
  - !ruby/object:Gem::Version
130
131
  version: '0'
131
- name: guard-rspec
132
- prerelease: false
133
132
  type: :development
133
+ prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
+ name: coveralls
140
141
  requirement: !ruby/object:Gem::Requirement
141
142
  requirements:
142
143
  - - ">="
143
144
  - !ruby/object:Gem::Version
144
145
  version: '0'
145
- name: coveralls
146
+ type: :development
146
147
  prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: byebug
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
147
160
  type: :development
161
+ prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - ">="
@@ -197,7 +211,7 @@ homepage: https://github.com/cha55son/siren_client
197
211
  licenses:
198
212
  - MIT
199
213
  metadata: {}
200
- post_install_message:
214
+ post_install_message:
201
215
  rdoc_options: []
202
216
  require_paths:
203
217
  - lib
@@ -212,9 +226,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
226
  - !ruby/object:Gem::Version
213
227
  version: '0'
214
228
  requirements: []
215
- rubyforge_project:
216
- rubygems_version: 2.6.8
217
- signing_key:
229
+ rubyforge_project:
230
+ rubygems_version: 2.6.14
231
+ signing_key:
218
232
  specification_version: 4
219
233
  summary: A client to traverse Siren APIs https://github.com/kevinswiber/siren
220
234
  test_files: