spot-gps 0.2.1 → 0.2.2

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: 8313cb1f50ceb658a15e2b26ac1cd482866e371f
4
- data.tar.gz: 07b18f7b8c85a96e352ae60b06d39459edab4068
3
+ metadata.gz: 9d8b0903516cfa4fa8380df8b32e4dd8b7b99c48
4
+ data.tar.gz: 8027a9f30397682700e08ba08697bf4c08fe9105
5
5
  SHA512:
6
- metadata.gz: 7016d42d4a25ac8d760ce84459526e13b58c570404b410d4b920aa931d3486770b42f77ced2ff3df70fb6db840456f5b056710a935696f89b02045d0f2ac7f02
7
- data.tar.gz: 79bb4e3d101b91a5578c9981d4def1bddf78fd27a20df4cf67ae9e50abb9af9173d64248b21306fd36460c6505cb438ae8b0af8e27bf1c1d4f9b789abadb9367
6
+ metadata.gz: 6af5db30f5ca02f4defd81f2bce76f2664b6b2648d2583e15625ca1f3cec59f7edb55fb635199a69518b1bced687281ab90a81c32da5cfbc0d1f7d7b8cd4097e
7
+ data.tar.gz: c241257559dd44332de8868db7f7c3fbbca5f02258de2bbb8c20075ab5967e775f5f732eed5becbe13dd97e19891de6d8a470c4cda6019d9b34c35cd4b8ae00b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.2.2, 17 July 2016
2
+
3
+ - Don't include password in querystring when it's blank
4
+ - Handle "no-messages" response when asking for latest message
5
+
1
6
  ## v0.2.1, 16 July 2016
2
7
 
3
8
  - Add support for Ruby 2.2 and 2.1.
@@ -20,7 +20,10 @@ module SPOT
20
20
  # Make a GET request to the SPOT API
21
21
  def get(path:, params: {})
22
22
  params ||= {}
23
- params = params.merge(feedPassword: feed_password) if feed_password
23
+
24
+ if feed_password && !feed_password.empty?
25
+ params = params.merge(feedPassword: feed_password)
26
+ end
24
27
 
25
28
  response = make_request(:get, path, params)
26
29
 
@@ -29,7 +29,10 @@ module SPOT
29
29
 
30
30
  def latest
31
31
  response = get(path: "latest.json")
32
- Resources::Message.new(unenvelope_body(response.body), response)
32
+ unenveloped_body = unenvelope_body(response.body)
33
+
34
+ return nil if unenveloped_body.nil?
35
+ Resources::Message.new(unenveloped_body, response)
33
36
  end
34
37
 
35
38
  private
@@ -1,3 +1,3 @@
1
1
  module SPOT
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
@@ -29,6 +29,17 @@ describe SPOT::ApiService do
29
29
  to have_requested(:get, 'https://example.com/EXAMPLE_ID/messages.json').
30
30
  with(query: { feedPassword: 'password' })
31
31
  end
32
+
33
+ context 'that is blank' do
34
+ let(:password) { '' }
35
+
36
+ it 'is expected to not include the password in the querystring' do
37
+ service.get(path: 'messages.json')
38
+ expect(WebMock).
39
+ to have_requested(:get, 'https://example.com/EXAMPLE_ID/messages.json').
40
+ with(query: {})
41
+ end
42
+ end
32
43
  end
33
44
  end
34
45
 
@@ -217,5 +217,17 @@ describe SPOT::Services::Messages do
217
217
 
218
218
  it { is_expected.to be_a(SPOT::Resources::Message) }
219
219
  its(:response) { is_expected.to be_a(SPOT::ApiResponse) }
220
+
221
+ context "with no records" do
222
+ before do
223
+ stub_url = SPOT.endpoint + 'EXAMPLE_ID/latest.json'
224
+ stub_request(:get, stub_url).to_return(
225
+ body: load_fixture('no_messages.json'),
226
+ headers: { 'Content-Type' => 'application/json' }
227
+ )
228
+ end
229
+
230
+ it { is_expected.to be_nil }
231
+ end
220
232
  end
221
233
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spot-gps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grey Baker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-16 00:00:00.000000000 Z
11
+ date: 2016-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webmock