active_rest_client 1.0.1 → 1.0.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: 287ff0756e1a325c054bb32e601270ebe459b6c9
4
- data.tar.gz: 28d6c1a06dde0da5872a96683731ad07741e0159
3
+ metadata.gz: b673b275ac742495303d8632a70e7a2425df69bf
4
+ data.tar.gz: 99edc9e4f9ec9faa7703449685c48b898196ee15
5
5
  SHA512:
6
- metadata.gz: 0081d8815d8bfa568980695683ae889afc68c6f782acfc6759b166f205d0b033c5788ee8973e6ac2e66abd42c9906affbe0913ec71064532009b1626427638f8
7
- data.tar.gz: 518e02c69f5239f0528d57dfaba126224dc1e0a4b766d8920a6df50bdfecf3b15d05dd3e4c170c16b23ac70614db98573790a8790cff1c70f1cfd4477e477039
6
+ metadata.gz: ea15068289c7bedc5faee76611548e342e8ba395f4bb76fb81f99395d5f3fad10e0936a94df5eac5c45236adf137b9ade25c7553a7828c44ad4e83d2d23be3e9
7
+ data.tar.gz: d201d14a7563791a12885ffb7967f58c938194cd979d06c779b42db11cb0792f336d6f7993ad1e21cd8985cfddc05ff8f4522d098b9b5d733f6ba8c62c41af25
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
- spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "rspec", "~> 2"
25
25
  spec.add_development_dependency "webmock"
26
26
  spec.add_development_dependency "rspec_junit_formatter"
27
27
  spec.add_development_dependency "simplecov"
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_runtime_dependency "multi_json"
34
34
  spec.add_runtime_dependency "activesupport"
35
35
  spec.add_runtime_dependency "faraday", "~> 0.9"
36
- spec.add_runtime_dependency "patron", ">= 0.4.9" # 0.4.18 breaks against Curl v0.7.15 but works with webmock
36
+ spec.add_development_dependency "patron", ">= 0.4.9" # 0.4.18 breaks against Curl v0.7.15 but works with webmock
37
37
  end
@@ -6,7 +6,8 @@ module ActiveRestClient
6
6
 
7
7
  def initialize(name, value, request, options = {})
8
8
  @name = name
9
- @request = request
9
+ class_to_map = request.method[:options][:lazy][name] rescue nil
10
+ @request = class_to_map.nil? ? request : ActiveRestClient::Request.new(class_to_map._mapped_method(:find), class_to_map.new, options)
10
11
  @object = nil
11
12
  @options = options
12
13
  if value.is_a? Array
@@ -1,3 +1,3 @@
1
1
  module ActiveRestClient
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -1,5 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
+ class MonthExample < ActiveRestClient::Base
4
+ base_url "http://www.example.com"
5
+
6
+ get :find, "/month/:id", fake:"{\"name\":\"january\"}"
7
+ end
8
+
9
+ class YearExample < ActiveRestClient::Base
10
+ base_url "http://www.example.com"
11
+
12
+ get :find, "/year/:id", lazy: { months: MonthExample }, fake: "{\"months\": [\"http://www.example.com/months/1\"] }"
13
+ end
14
+
3
15
  describe ActiveRestClient::LazyAssociationLoader do
4
16
  let(:url1) { "http://www.example.com/some/url" }
5
17
  let(:url2) { "http://www.example.com/some/other" }
@@ -115,4 +127,9 @@ describe ActiveRestClient::LazyAssociationLoader do
115
127
  ActiveRestClient::Request.any_instance.should_receive(:call).with(any_args).and_return([1,2,3])
116
128
  expect(loader.size).to eq(3)
117
129
  end
130
+
131
+ it "should use the class specified in the 'lazy' declaration to parse the response rather than the class of the object the lazy loader is attached to" do
132
+ association = YearExample.find(1)
133
+ expect(association.months.instance_variable_get('@request').instance_variable_get('@object').class).to eq(MonthExample)
134
+ end
118
135
  end
data/spec/spec_helper.rb CHANGED
@@ -13,7 +13,7 @@ elsif ENV["TRAVIS"]
13
13
  end
14
14
 
15
15
  RSpec.configure do |config|
16
- config.color_enabled = true
16
+ config.color = true
17
17
  # config.formatter = 'documentation'
18
18
 
19
19
  config.treat_symbols_as_metadata_keys_with_true_values = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_rest_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Which Ltd
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-03 00:00:00.000000000 Z
12
+ date: 2014-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -43,16 +43,16 @@ dependencies:
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: '2'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: '2'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: webmock
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -200,7 +200,7 @@ dependencies:
200
200
  - - ">="
201
201
  - !ruby/object:Gem::Version
202
202
  version: 0.4.9
203
- type: :runtime
203
+ type: :development
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements: