webstub 1.1.4 → 1.1.5

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: 3a2fde9e9d4804340eb7277944fb7eb0209a15c8
4
- data.tar.gz: 48037f7211c379455be860d31f6f1a62fecbe422
3
+ metadata.gz: 04b972f94008e25abfc07c6a231f1059096fd373
4
+ data.tar.gz: 66ad2d78a3acbf68cd9969b567132aba5c9732a0
5
5
  SHA512:
6
- metadata.gz: 0d5d5de8974ee5fa30d38d6c8092d4c42ef1b8bccf6bead31678fc44141a069fcc39174f7d0e19ce210141f8a6c58b69a64d85c2da0f429c67d28d0d99023cca
7
- data.tar.gz: cdfae6a5dd49a258865d8374041836a4202ceedf98b5598a052df91338cd639e1a6cbcd63b3ef863191a1c269a1f3ec8a144fc4264559f801f5f3007a31b5d05
6
+ metadata.gz: 0657ad2907f0c68e4c67c9f3163baca97a533ca877fcc98e29b02345375abcbd513638d05069260c03ae72413af7cea7beef8ad6007d51bb680a307678b121e2
7
+ data.tar.gz: 2a2f70ad81fece0abc1fcf55bec14fe4634167b638a816578dd4af23c9ae7702916b291b8685ebc16fa8b4a43dab68796cf8e73498b61612214d5298d34aff76
data/Rakefile CHANGED
@@ -29,8 +29,10 @@ Motion::Project::App.setup do |app|
29
29
  app.files << File.join(File.dirname(__FILE__), "lib/spec/spec_delegate.rb")
30
30
  app.delegate_class = "SpecDelegate"
31
31
  app.resources_dirs = %w(spec/resources/images)
32
+ app.info_plist['NSAppTransportSecurity'] = {
33
+ 'NSAllowsArbitraryLoads' => true
34
+ }
32
35
  end
33
36
 
34
37
  app.name = gem_name
35
38
  end
36
-
@@ -82,7 +82,7 @@ module WebStub
82
82
  def startLoading
83
83
  request = self.request
84
84
  client = self.client
85
-
85
+
86
86
  unless @stub = self.class.stub_for(self.request)
87
87
  error = NSError.errorWithDomain("WebStub", code:0, userInfo:{ NSLocalizedDescriptionKey: "network access is not permitted!"})
88
88
  client.URLProtocol(self, didFailWithError:error)
@@ -90,9 +90,7 @@ module WebStub
90
90
  return
91
91
  end
92
92
 
93
- if body = self.class.parse_body(request)
94
- @stub.do_callback(self.request.allHTTPHeaderFields, body)
95
- end
93
+ @stub.do_callback(self.request.allHTTPHeaderFields || {}, self.class.parse_body(request))
96
94
  @timer = NSTimer.scheduledTimerWithTimeInterval(@stub.response_delay, target:self, selector: :completeLoading, userInfo:nil, repeats:false)
97
95
  end
98
96
 
@@ -1,3 +1,3 @@
1
1
  module WebStub
2
- VERSION = "1.1.4"
2
+ VERSION = "1.1.5"
3
3
  end
data/spec/api_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  describe WebStub::API do
2
2
  before do
3
3
  WebStub::API.reset_stubs
4
-
4
+
5
5
  @url = "http://www.example.com/"
6
6
  @request = NSURLRequest.requestWithURL(NSURL.URLWithString(@url))
7
7
  end
@@ -10,7 +10,7 @@ describe WebStub::API do
10
10
  it "returns the newly added stub" do
11
11
  WebStub::API.stub_request(:get, @url).should.not.be.nil
12
12
  end
13
-
13
+
14
14
  before { WebStub::API.disable_network_access! }
15
15
  after { WebStub::API.enable_network_access! }
16
16
 
@@ -146,18 +146,24 @@ describe WebStub::API do
146
146
 
147
147
  describe "when a stub sets a callback" do
148
148
 
149
- before do
150
- @stub = WebStub::API.stub_request(:post, @url)
151
- end
152
-
153
149
  it "calls the callback with header and body passed in" do
154
- @stub.with_callback do |headers, body|
150
+ stub = WebStub::API.stub_request(:post, @url)
151
+ stub.with_callback do |headers, body|
155
152
  body.should == {"q" => "hello"}
156
153
  body.kind_of?(Hash).should.be.true
157
- headers.kind_of?(Hash).should.be.true
154
+ headers.kind_of?(Hash).should.be.true
158
155
  end
159
156
  @response = post @url, :q => "hello"
160
157
  end
158
+
159
+ it "calls the callback with just the header passed in" do
160
+ stub = WebStub::API.stub_request(:get, @url)
161
+ stub.with_callback do |headers, body|
162
+ body.should.be.nil
163
+ headers.kind_of?(Hash).should.be.true
164
+ end
165
+ @response = get @url
166
+ end
161
167
  end
162
168
 
163
169
  describe "when a stub sets a delay" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webstub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake