activeresource-response 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDkwODM4ZTI1ZGZlNmMyOTM0OGY3YzE5YzIxOGFhMDgxYWQ1ZGFiYg==
4
+ OWYyODcxM2M3ZjJmZDk3YmRlOTVjY2E1NjZlOGMwZGEzN2MzNDE3OQ==
5
5
  data.tar.gz: !binary |-
6
- ZGY3NmM2OGNiYTZiOGNkOTExOGNhYzQzNTYxNDZhNzRhOGY4MDlmNw==
6
+ Y2I1NmZlNDI0ZGNkMmIyMDk2ZDhlNDkzNTU5YjZmNjAzYjMxNGYzNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzkwMGY3ODk4MzJkZGY3MTNiOTg3ODJhZGVkM2QwNTFkMTdkY2IyYTlhODg5
10
- MDg3Yjg5OGI0YmMzMWY2MjMwYThmMjNkZGEwYjFjYjM4MzE0YTU5NDI3NjFj
11
- ZGYxYjMyYmI4NzVlNDI5MDRkNDJmYmViMDk0OTI1ODNiNDFhNzY=
9
+ NTRmNzAxYTczMGRhNjBmZjEwMmM4MDA0YmI5MmVjZDgwOTc1ZTc2ZDAwZWQ4
10
+ ZjY5Mjc5YjM3ZmIyZDVlN2ZkOGM5Y2U5MTkxMzgxNmM5MjJhMjhhOTU1ZDNl
11
+ ZjUzMmM5MWQyM2I0NDYxZWYxZGJkOGE3YzJjMTIzZGM3ODM4MjM=
12
12
  data.tar.gz: !binary |-
13
- ODg5Yzk1NTcyZDIzZjA2MmI3OTg5Mzc0ZDE5MDliN2IxMTc1MmRjMTRlZjU5
14
- MzViYWVkNDM3ZTAxMmEzZjllMDc2YjhhYmVkZWQ4ODFjMDM1Njc2MDMzYTU0
15
- MWRkZjhlODNkN2U5MzYwOGQzNzIwMWM3NzcyMDFiNjEyZDhiMDc=
13
+ YTk1ZjZlZmY4YTMxY2MyYmIyYzNmZGRlYWY1OGE0NTE1YTkxZTI1YmNmMDhk
14
+ MTE1YmIxYmYwMWY1Mzg1NDk4OTJlMGRkYjllMzc3NWFkYjE2YWQwNjhkODY1
15
+ YzQzYmEzN2Q3NDU4ZDJhODQxNjBhZTRmMzNlMzRjZjM4NGQyYmY=
@@ -2,6 +2,5 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - jruby-19mode
5
- - rbx-19mode
6
- - 2.0.0
5
+ - 2.1.0
7
6
  - jruby-head
@@ -121,6 +121,13 @@ Example
121
121
  http response is object of Net::HTTPOK, Net::HTTPClientError or one of other subclasses
122
122
  of Net::HTTPResponse class. For more information see documentation http://www.ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTPResponse.html
123
123
 
124
+ == Testing with ActiveResource::HttpMock
125
+ Add this line to your test to patch http_mock
126
+
127
+ # require "active_resource_response/http_mock"
124
128
 
125
129
  == Please, feel free to contact me if you have any questions
126
130
  fedoronchuk(at)gmail.com
131
+
132
+
133
+ {<img src="https://d2weczhvl823v0.cloudfront.net/Fivell/activeresource-response/trend.png" />}[https://bitdeli.com/free]
@@ -21,6 +21,7 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
  require 'active_resource/http_mock'
24
+
24
25
  module ActiveResourceResponse
25
26
  module HttpMock
26
27
  module Response
@@ -28,7 +29,11 @@ module ActiveResourceResponse
28
29
  def self.included(base)
29
30
  base.class_eval do
30
31
  def to_hash
31
- @headers
32
+ Hash[@headers.map{|k, value| [k, Array.wrap(value)] } ]
33
+ end
34
+
35
+ def [](key)
36
+ @headers[key]
32
37
  end
33
38
  end
34
39
  end
@@ -36,4 +41,4 @@ module ActiveResourceResponse
36
41
  end
37
42
  end
38
43
 
39
- ActiveResource::Response.send :include, ActiveResourceResponse::HttpMock::Response
44
+ ActiveResource::Response.send :include, ActiveResourceResponse::HttpMock::Response
@@ -23,6 +23,6 @@
23
23
 
24
24
  module ActiveResourceResponse
25
25
  module Version
26
- VERSION = "1.0.2"
26
+ VERSION = "1.1.0"
27
27
  end
28
28
  end
@@ -79,14 +79,15 @@ class ActiveResourceResponseTest < Test::Unit::TestCase
79
79
  countries = Country.all
80
80
  assert_kind_of Country, countries.first
81
81
  assert_equal "UA", countries.first.iso
82
- assert_equal countries.http.headers[:x_total].to_i, 1
82
+ assert_equal countries.http.headers[:x_total].first.to_i, 1
83
83
  end
84
84
 
85
85
 
86
86
  def test_get_headers_from_custom_methods
87
87
  cities = Region.get("cities")
88
88
  assert cities.respond_to?(:http_response)
89
- assert_equal cities.http_response.headers[:x_total].to_i, 2
89
+ assert_equal cities.http_response.headers[:x_total].first.to_i, 2
90
+ assert_equal cities.http_response['X-total'].to_i, 2
90
91
  count = Country.find(1).get("population")
91
92
 
92
93
  #immutable objects doing good
@@ -95,16 +96,17 @@ class ActiveResourceResponseTest < Test::Unit::TestCase
95
96
  assert count.respond_to?(:http)
96
97
  assert !some_numeric.respond_to?(:http)
97
98
 
98
- assert_equal Country.connection.http_response.headers[:x_total].to_i, 1
99
- assert_equal Country.http_response.headers[:x_total].to_i, 1
99
+ assert_equal Country.connection.http_response.headers[:x_total].first.to_i, 1
100
+ assert_equal Country.http_response.headers[:x_total].first.to_i, 1
101
+ assert_equal Country.http_response['X-total'].to_i, 1
100
102
  cities = Country.find(1).get("cities")
101
103
  assert cities.respond_to?(:http), "Cities should respond to http"
102
- assert_equal cities.http.headers[:x_total].to_i, 1, "Cities total value should be 1"
104
+ assert_equal cities.http.headers[:x_total].first.to_i, 1, "Cities total value should be 1"
103
105
  regions_population = Region.get("population")
104
106
  assert_equal regions_population.to_i, 45000000
105
107
  cities = Region.find(1).get("cities")
106
108
  assert cities.respond_to?(:http_response)
107
- assert_equal cities.http_response.headers[:x_total].to_i, 1
109
+ assert_equal cities.http_response.headers[:x_total], ['1']
108
110
 
109
111
  end
110
112
 
@@ -119,7 +121,7 @@ class ActiveResourceResponseTest < Test::Unit::TestCase
119
121
 
120
122
  def test_get_headers_from_find
121
123
  country = Country.find(1)
122
- assert_equal country.http.headers[:x_total].to_i, 1
124
+ assert_equal country.http.headers[:x_total], ['1']
123
125
  end
124
126
 
125
127
  def test_get_cookies
@@ -134,7 +136,7 @@ class ActiveResourceResponseTest < Test::Unit::TestCase
134
136
 
135
137
  def test_get_headers_after_exception
136
138
  country = Country.create(@country[:country])
137
- assert_equal Country.http_response.headers[:x_total].to_i, 1
139
+ assert_equal Country.http_response.headers[:x_total], ['1']
138
140
  assert_equal Country.http_response.code, 422
139
141
  assert_equal country.errors.full_messages.count ,1
140
142
  assert_equal country.errors.count ,1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeresource-response
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Fedoronchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-06 00:00:00.000000000 Z
11
+ date: 2014-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -115,4 +115,3 @@ test_files:
115
115
  - test/fixtures/region.rb
116
116
  - test/fixtures/street.rb
117
117
  - test/lint_test.rb
118
- has_rdoc: