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 +4 -4
- data/Rakefile +3 -1
- data/lib/webstub/protocol.rb +2 -4
- data/lib/webstub/version.rb +1 -1
- data/spec/api_spec.rb +14 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04b972f94008e25abfc07c6a231f1059096fd373
|
4
|
+
data.tar.gz: 66ad2d78a3acbf68cd9969b567132aba5c9732a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
data/lib/webstub/protocol.rb
CHANGED
@@ -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
|
-
|
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
|
|
data/lib/webstub/version.rb
CHANGED
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
|
-
|
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
|
+
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-
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|