afmotion 2.2.0 → 2.3.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: a90bbeab670fa163a23a4a02b4c9e0adbb8c2edb
4
- data.tar.gz: b713abfe1188c39566ae6787a2732f1c615c8cf5
3
+ metadata.gz: 9c957c44c8f314d56ba6de33807ee4abaa7a842e
4
+ data.tar.gz: d15335cebcadd474f2ba2931d8172f8a3eb56c61
5
5
  SHA512:
6
- metadata.gz: 56effec5e307c84dc035f793c25d210d713421e704db149033dcbf16f1cbf499c6e701785b30134e4c914da916261dca4e9b4822f9369862a9ce64a41c87fdeb
7
- data.tar.gz: ec5008be1781a1e21388bed27e1498c3a26c3e8d26f7adc481902df7db629c2f95206d6c53c0c0e4d6c1a49ee82e7ce1b58df3e5088a5162e23056846531a28a
6
+ metadata.gz: 1d4e7deb050500b64ff7dc762723efe7761587c96467696c83edd3a82ab8b21bb760105a776791551d115a628fe0b99842faecd7623d16c2907f1f8958e9a96a
7
+ data.tar.gz: 084984dcf52bc788c36c05e26a004e16f2a1d5af89fd48bd6986842e62f5515efce55d75ded1d6f28d027b980d631c060bf1faa01cd6ec3711f02eb8ab13408f
@@ -18,4 +18,5 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency "motion-cocoapods", ">= 1.4.1"
19
19
  s.add_dependency "motion-require", ">= 0.1"
20
20
  s.add_development_dependency 'rake'
21
+ s.add_development_dependency 'webstub'
21
22
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- afmotion (2.2.0)
4
+ afmotion (2.3.1)
5
5
  motion-cocoapods (>= 1.4.1)
6
6
  motion-require (>= 0.1)
7
7
 
@@ -48,10 +48,11 @@ GEM
48
48
  cocoapods (>= 0.32.1)
49
49
  motion-require (0.2.0)
50
50
  multi_json (1.10.1)
51
- nap (0.7.0)
51
+ nap (0.8.0)
52
52
  netrc (0.7.7)
53
53
  open4 (1.3.4)
54
- rake (10.1.0)
54
+ rake (10.3.2)
55
+ webstub (1.0.1)
55
56
  xcodeproj (0.17.0)
56
57
  activesupport (~> 3.0)
57
58
  colored (~> 1.2)
@@ -62,3 +63,4 @@ PLATFORMS
62
63
  DEPENDENCIES
63
64
  afmotion!
64
65
  rake
66
+ webstub
data/Rakefile CHANGED
@@ -8,6 +8,8 @@ Bundler.require :default
8
8
  $:.unshift("./lib/")
9
9
  require './lib/afmotion'
10
10
 
11
+ require 'webstub'
12
+
11
13
  Motion::Project::App.setup do |app|
12
14
  # Use `rake config' to see complete project settings.
13
15
  app.name = 'AFMotion'
@@ -16,6 +16,6 @@ Motion::Project::App.setup do |app|
16
16
  end
17
17
 
18
18
  app.pods do
19
- pod 'AFNetworking', '~> 2.2.4'
19
+ pod 'AFNetworking', '~> 2.3.1'
20
20
  end
21
21
  end
@@ -18,6 +18,7 @@ module AFMotion
18
18
  class JSON < HTTP
19
19
  def self.configure_manager(manager)
20
20
  manager.json!
21
+ manager.responseSerializer.readingOptions = NSJSONReadingMutableContainers
21
22
  end
22
23
  end
23
24
 
@@ -73,13 +73,20 @@ module AFMotion
73
73
  form: AFHTTPResponseSerializer
74
74
  }
75
75
  def response_serializer(serializer)
76
+ write_json_options = true
76
77
  if serializer.is_a?(Symbol) || serializer.is_a?(String)
77
78
  @operation_manager.responseSerializer = OPERATION_TO_RESPONSE_SERIALIZER[serializer.to_sym].serializer
78
79
  elsif serializer.is_a?(Class)
79
80
  @operation_manager.responseSerializer = serializer.serializer
80
81
  else
81
82
  @operation_manager.responseSerializer = serializer
83
+ write_json_options = false
82
84
  end
85
+ af_serializer = @operation_manager.responseSerializer
86
+ if af_serializer.is_a?(AFJSONResponseSerializer) && write_json_options
87
+ af_serializer.readingOptions = NSJSONReadingMutableContainers
88
+ end
89
+ af_serializer
83
90
  end
84
91
  end
85
92
  end
@@ -89,7 +96,7 @@ class AFHTTPRequestOperationManager
89
96
 
90
97
  AFMotion::HTTP_METHODS.each do |method|
91
98
  # EX client.get('my/resource.json')
92
- define_method "#{method}", -> (path, parameters = {}, &callback) do
99
+ define_method "#{method}", -> (path, parameters = nil, &callback) do
93
100
  create_operation(method, path, parameters, &callback)
94
101
  end
95
102
  end
@@ -1,5 +1,5 @@
1
1
  module AFMotion
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.1"
3
3
 
4
4
  HTTP_METHODS = [:get, :post, :put, :delete, :patch, :head]
5
5
  end
@@ -49,6 +49,16 @@ describe "AFMotion::ClientDSL" do
49
49
  @client.responseSerializer.is_a?(enc_class).should == true
50
50
  end
51
51
  end
52
+
53
+ it "should set mutable reading options for JSON serializer" do
54
+ @dsl.response_serializer :json
55
+ @client.responseSerializer.readingOptions.should == NSJSONReadingMutableContainers
56
+ end
57
+
58
+ it "should not set reading options for JSON serializer if raw one supplied" do
59
+ @dsl.response_serializer AFJSONResponseSerializer.serializer
60
+ @client.responseSerializer.readingOptions.should.not == NSJSONReadingMutableContainers
61
+ end
52
62
  end
53
63
  end
54
64
 
@@ -0,0 +1,69 @@
1
+ describe "AFMotion" do
2
+ extend WebStub::SpecHelpers
3
+
4
+ before do
5
+ disable_network_access!
6
+ end
7
+
8
+ after do
9
+ enable_network_access!
10
+ reset_stubs
11
+ end
12
+
13
+ describe "JSON" do
14
+ it "should use mutable containers" do
15
+ url = "http://example.com/"
16
+ stub_request(:get, url).
17
+ to_return(json: {"data" => ["thing"]}, delay: 0.3)
18
+
19
+ AFMotion::JSON.get(url) do |result|
20
+ @object = result.object
21
+ resume
22
+ end
23
+
24
+ wait_max 1.0 do
25
+ array = @object['data']
26
+ array << 'derp'
27
+ array.count.should == 2
28
+
29
+ @object['hello'] = 'world'
30
+ @object.count.should == 2
31
+
32
+ @object.delete('data')
33
+ @object.count.should == 1
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "Client" do
39
+ describe "JSON" do
40
+ it "should use mutable containers" do
41
+ base_url = "http://example.com/"
42
+ path = "path"
43
+ stub_request(:get, base_url + path).
44
+ to_return(json: {"data" => ["thing"]}, delay: 0.3)
45
+
46
+ client = AFMotion::Client.build(base_url) do
47
+ response_serializer :json
48
+ end
49
+
50
+ client.get(path, nil) do |result|
51
+ @object = result.object
52
+ resume
53
+ end
54
+
55
+ wait_max 1.0 do
56
+ array = @object['data']
57
+ array << 'derp'
58
+ array.count.should == 2
59
+
60
+ @object['hello'] = 'world'
61
+ @object.count.should == 2
62
+
63
+ @object.delete('data')
64
+ @object.count.should == 1
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -48,6 +48,16 @@ describe "AFMotion::SessionClientDSL" do
48
48
  @dsl.to_session_manager.responseSerializer.is_a?(enc_class).should == true
49
49
  end
50
50
  end
51
+
52
+ it "should set mutable reading options for JSON serializer" do
53
+ @dsl.response_serializer :json
54
+ @dsl.to_session_manager.responseSerializer.readingOptions.should == NSJSONReadingMutableContainers
55
+ end
56
+
57
+ it "should not set reading options for JSON serializer if raw one supplied" do
58
+ @dsl.response_serializer AFJSONResponseSerializer.serializer
59
+ @dsl.to_session_manager.responseSerializer.readingOptions.should.not == NSJSONReadingMutableContainers
60
+ end
51
61
  end
52
62
 
53
63
  describe "#session_configuration" do
@@ -1,28 +1,30 @@
1
1
  PODS:
2
- - AFNetworking (2.2.4):
2
+ - AFNetworking (2.3.1):
3
3
  - AFNetworking/NSURLConnection
4
4
  - AFNetworking/NSURLSession
5
5
  - AFNetworking/Reachability
6
6
  - AFNetworking/Security
7
7
  - AFNetworking/Serialization
8
8
  - AFNetworking/UIKit
9
- - AFNetworking/NSURLConnection (2.2.4):
9
+ - AFNetworking/NSURLConnection (2.3.1):
10
10
  - AFNetworking/Reachability
11
11
  - AFNetworking/Security
12
12
  - AFNetworking/Serialization
13
- - AFNetworking/NSURLSession (2.2.4):
14
- - AFNetworking/NSURLConnection
15
- - AFNetworking/Reachability (2.2.4)
16
- - AFNetworking/Security (2.2.4)
17
- - AFNetworking/Serialization (2.2.4)
18
- - AFNetworking/UIKit (2.2.4):
13
+ - AFNetworking/NSURLSession (2.3.1):
14
+ - AFNetworking/Reachability
15
+ - AFNetworking/Security
16
+ - AFNetworking/Serialization
17
+ - AFNetworking/Reachability (2.3.1)
18
+ - AFNetworking/Security (2.3.1)
19
+ - AFNetworking/Serialization (2.3.1)
20
+ - AFNetworking/UIKit (2.3.1):
19
21
  - AFNetworking/NSURLConnection
20
22
  - AFNetworking/NSURLSession
21
23
 
22
24
  DEPENDENCIES:
23
- - AFNetworking (~> 2.2.4)
25
+ - AFNetworking (~> 2.3.1)
24
26
 
25
27
  SPEC CHECKSUMS:
26
- AFNetworking: ab63e259fe91eef4519b371ef0a4955af0e73e64
28
+ AFNetworking: 6d7b76aa5d04c8c37daad3eef4b7e3f2a7620da3
27
29
 
28
30
  COCOAPODS: 0.33.1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afmotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clay Allsopp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: motion-cocoapods
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webstub
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: A RubyMotion Wrapper for AFNetworking
56
70
  email:
57
71
  - clay.allsopp@gmail.com
@@ -82,6 +96,7 @@ files:
82
96
  - resources/test.png
83
97
  - spec/http_client_spec.rb
84
98
  - spec/http_spec.rb
99
+ - spec/integration_spec.rb
85
100
  - spec/session_client_spec.rb
86
101
  - vendor/Podfile.lock
87
102
  homepage: https://github.com/clayallsopp/AFMotion
@@ -111,4 +126,5 @@ summary: A RubyMotion Wrapper for AFNetworking
111
126
  test_files:
112
127
  - spec/http_client_spec.rb
113
128
  - spec/http_spec.rb
129
+ - spec/integration_spec.rb
114
130
  - spec/session_client_spec.rb