webstub 1.1.1 → 1.1.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: 40544713a0826d109fcb02e4783588517437b435
4
- data.tar.gz: 46b02687ec96a9a3f46cb59695964e8285de78ee
3
+ metadata.gz: 417c4590e0317c76435c058817bf99abf978ed1d
4
+ data.tar.gz: b4bdc1d2000e39c50545b09e08ca84ecc869c047
5
5
  SHA512:
6
- metadata.gz: 93aab16995e60f7dc7ac17b35063ea5b7418558f50d9bbb1483e52c7ea02cadcfb4d84362b7e858f182f5d183f325c453ba6e0db12ca0c43b895acc99a45a1ce
7
- data.tar.gz: 822c71d00fca97e051b6a112ea4221540f364d775b8517ee6ea2afdb39ca2b7825672e8668c55820ad075d56006d4485d5f526eb8ebfe7469206c2ba08327651
6
+ metadata.gz: c510ac76a7fffb353a52e2c0090bac01b92a5940fdd74c94bf3d66e5647b1fa4449aad9a99b7a5d36d7ab692b9e3ecb08075f99ebe6ce200827ee8841f8d2253
7
+ data.tar.gz: 844d47d28fdcf93b6700297623da1177b631bdf1fe236c752a1eec4cddaf33b5c44cb6f9e1e739c013f11f7157bf5a248ec04c52629925a6d38051c6a91a1111
@@ -6,9 +6,9 @@ if Kernel.const_defined?(:NSURLSessionConfiguration)
6
6
  def defaultSessionConfiguration
7
7
  config = originalDefaultSessionConfiguration
8
8
 
9
- protocols = config.protocolClasses.clone || []
9
+ protocols = (config.protocolClasses && config.protocolClasses.clone) || []
10
10
  unless protocols.include?(WebStub::Protocol)
11
- protocols << WebStub::Protocol
11
+ protocols.unshift WebStub::Protocol
12
12
  config.protocolClasses = protocols
13
13
  end
14
14
 
@@ -20,9 +20,9 @@ if Kernel.const_defined?(:NSURLSessionConfiguration)
20
20
  def ephemeralSessionConfiguration
21
21
  config = originalEphemeralSessionConfiguration
22
22
 
23
- protocols = config.protocolClasses.clone || []
23
+ protocols = (config.protocolClasses && config.protocolClasses.clone) || []
24
24
  unless protocols.include?(WebStub::Protocol)
25
- protocols << WebStub::Protocol
25
+ protocols.unshift WebStub::Protocol
26
26
  config.protocolClasses = protocols
27
27
  end
28
28
 
@@ -7,7 +7,7 @@ module WebStub
7
7
  raise ArgumentError, "invalid method name" unless METHODS.include? @request_method
8
8
 
9
9
  @requests = 0
10
-
10
+
11
11
  @request_url = canonicalize_url(url)
12
12
  @request_headers = nil
13
13
  @request_body = nil
@@ -75,7 +75,7 @@ module WebStub
75
75
  elsif code = options.delete(:code)
76
76
  @response_error = NSError.errorWithDomain(NSURLErrorDomain, code: code, userInfo: nil)
77
77
  else
78
- raise ArgumentError, "to_fail requires either the code or error option"
78
+ raise ArgumentError, "to_fail requires either the code or error option"
79
79
  end
80
80
 
81
81
  self
@@ -180,11 +180,11 @@ module WebStub
180
180
  parts << path
181
181
  end
182
182
 
183
- if query
183
+ if query && !query.empty?
184
184
  parts << "?#{query}"
185
185
  end
186
186
 
187
- if fragment
187
+ if fragment && !fragment.empty?
188
188
  parts << "##{fragment}"
189
189
  end
190
190
 
@@ -1,3 +1,3 @@
1
1
  module WebStub
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -47,7 +47,7 @@ describe WebStub::Stub do
47
47
  end
48
48
  end
49
49
  it "calls the callback method" do
50
- @stub.callback.should.not.be.nil
50
+ @stub.callback.should.not.be.nil
51
51
  end
52
52
  it "should call the callback" do
53
53
  @stub.do_callback("headers", "body")
@@ -90,6 +90,14 @@ describe WebStub::Stub do
90
90
  it "ignores a path with \"/\"" do
91
91
  @stub.matches?(:get, "http://www.yahoo.com:80/").should.be.true
92
92
  end
93
+
94
+ it 'strips any trailing ?' do
95
+ @stub.matches?(:get, "http://www.yahoo.com/?").should.be.true
96
+ end
97
+
98
+ it 'strips any trailing #' do
99
+ @stub.matches?(:get, "http://www.yahoo.com/#").should.be.true
100
+ end
93
101
  end
94
102
 
95
103
  describe "body" do
@@ -100,7 +108,7 @@ describe WebStub::Stub do
100
108
  end
101
109
 
102
110
  it "returns false when the body does not match" do
103
- @stub.matches?(:post, "http://www.yahoo.com/search", { :body => {}}).should.be.false
111
+ @stub.matches?(:post, "http://www.yahoo.com/search", { :body => {}}).should.be.false
104
112
  end
105
113
 
106
114
  it "returns true when the body matches (with string keys)" do
@@ -135,12 +143,12 @@ describe WebStub::Stub do
135
143
  end
136
144
 
137
145
  it "returns true when the headers are included" do
138
- @stub.matches?(:get, "http://www.yahoo.com/search",
146
+ @stub.matches?(:get, "http://www.yahoo.com/search",
139
147
  headers: { "X-Extra" => "42", "Authorization" => "secret" }).should.be.true
140
148
  end
141
149
 
142
150
  it "returns false when any of the headers are absent" do
143
- @stub.matches?(:get, "http://www.yahoo.com/search",
151
+ @stub.matches?(:get, "http://www.yahoo.com/search",
144
152
  headers: { "X-Extra" => "42" }).should.be.false
145
153
  end
146
154
  end
@@ -166,7 +174,7 @@ describe WebStub::Stub do
166
174
 
167
175
  describe "#response_body" do
168
176
  it "returns the response body" do
169
- @stub.response_body.should == ""
177
+ @stub.response_body.should == ""
170
178
  end
171
179
  end
172
180
 
@@ -247,7 +255,7 @@ describe WebStub::Stub do
247
255
 
248
256
  it "sets response headers" do
249
257
  @stub.to_return(body: "{}", headers: { "Content-Type" => "application/json" })
250
- @stub.response_headers.should.be == { "Content-Type" => "application/json" }
258
+ @stub.response_headers.should.be == { "Content-Type" => "application/json" }
251
259
  end
252
260
 
253
261
  it "sets the response status code" 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.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-18 00:00:00.000000000 Z
11
+ date: 2014-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake