hypertext_client 0.0.7 → 0.0.8

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.8 (October 11, 2010)
2
+
3
+ Improved logic for processing id parameter to http methods
4
+
1
5
  ## 0.0.7 (October 11, 2010)
2
6
 
3
7
  Properly set camel cased parent class name
@@ -18,7 +18,7 @@
18
18
 
19
19
  # Hypertext provides an HTTP client based on HTTParty, with a few assumptions baked in.
20
20
  module HypertextClient
21
- VERSION = '0.0.7'
21
+ VERSION = '0.0.8'
22
22
 
23
23
  extend ActiveSupport::Concern
24
24
  # Include HTTParty
@@ -105,10 +105,11 @@ module HypertextClient
105
105
  end
106
106
 
107
107
  path = args.shift
108
- if (path.class == String)
109
- path = '/' + path unless path =~ %r(http://) || path.chars.first == '/'
108
+ unless (path.is_a?(Hash) || path.is_a?(Array))
109
+ path = path.to_s
110
+ path = '/' + path unless path.nil? || path =~ %r(http://) || path.chars.first == '/'
110
111
  else
111
- args.unshift path unless path.nil?
112
+ args.unshift path
112
113
  path = ''
113
114
  end
114
115
 
@@ -12,7 +12,7 @@ FAKE_ENDPOINT = "http://api.skynetinc.com"
12
12
 
13
13
  FakeWeb.allow_net_connect = false
14
14
  FakeWeb.register_uri(:get,
15
- FAKE_ENDPOINT + '/widgets',
15
+ FAKE_ENDPOINT + '/widgets/?',
16
16
  :body => ([{:foo => 1}] * 5).to_json,
17
17
  :content_type => 'application/json')
18
18
 
@@ -42,7 +42,12 @@ FakeWeb.register_uri(:get,
42
42
  :body => {:property => 'exists'}.to_json,
43
43
  :content_type => 'application/json')
44
44
 
45
- FakeWeb.register_uri(:get,
45
+ FakeWeb.register_uri(:any,
46
+ FAKE_ENDPOINT + '/camel_cases/example/camel_case_inheritors',
47
+ :body => [{:property => 'exists'}].to_json,
48
+ :content_type => 'application/json')
49
+
50
+ FakeWeb.register_uri(:any,
46
51
  FAKE_ENDPOINT + '/camel_cases/example/camel_case_inheritors/123',
47
52
  :body => {:property => 'exists'}.to_json,
48
53
  :content_type => 'application/json')
@@ -146,4 +151,19 @@ class HypertextClientTest < MiniTest::Unit::TestCase
146
151
  example = SkynetClient::CamelCaseInheritor.get('123', :camel_case => 'example')
147
152
  assert example
148
153
  end
154
+
155
+ def test_requires_camelcase_id
156
+ example = SkynetClient::CamelCaseInheritor.delete('123', :camel_case => 'example')
157
+ assert_equal '/camel_cases/example/camel_case_inheritors/123', FakeWeb.last_request.path
158
+ end
159
+
160
+ def test_build_url_non_string_for_sub_model
161
+ example = SkynetClient::CamelCaseInheritor.delete(123, :camel_case => 'example')
162
+ assert_equal '/camel_cases/example/camel_case_inheritors/123', FakeWeb.last_request.path
163
+ end
164
+
165
+ def test_build_collection_url_from_hash_for_sub_model
166
+ example = SkynetClient::CamelCaseInheritor.get(:camel_case => 'example')
167
+ assert_equal '/camel_cases/example/camel_case_inheritors', FakeWeb.last_request.path
168
+ end
149
169
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 7
9
- version: 0.0.7
8
+ - 8
9
+ version: 0.0.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Quid, Inc.