webmock 1.8.5 → 1.8.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.6
4
+
5
+ * Pass through SERVER_PORT when stubbing to rack
6
+
7
+ Thanks to [Eric Oestrich](https://github.com/oestrich)
8
+
9
+ * Fixed problem with missing parenthesis in `WebMock#net_connect_allowed?` conditions.
10
+
11
+ Thanks to [aindustries](https://github.com/aindustries)
12
+
3
13
  ## 1.8.5
4
14
 
5
15
  * WebMock::RackResponse supports basic auth
data/README.md CHANGED
@@ -703,6 +703,8 @@ People who submitted patches and new features or suggested improvements. Many th
703
703
  * Joe Karayusuf
704
704
  * Paul Cortens
705
705
  * jugyo
706
+ * aindustries
707
+ * Eric Oestrich
706
708
 
707
709
  For a full list of contributors you can visit the
708
710
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -35,7 +35,8 @@ module WebMock
35
35
  'CONTENT_LENGTH' => body.size,
36
36
  'PATH_INFO' => uri.path,
37
37
  'QUERY_STRING' => uri.query || '',
38
- 'SERVER_NAME' => uri.host
38
+ 'SERVER_NAME' => uri.host,
39
+ 'SERVER_PORT' => uri.port
39
40
  }
40
41
 
41
42
  env['HTTP_AUTHORIZATION'] = 'Basic ' + [uri.userinfo].pack('m').delete("\r\n") if uri.userinfo
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '1.8.5' unless defined?(::WebMock::VERSION)
2
+ VERSION = '1.8.6' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -57,12 +57,20 @@ module WebMock
57
57
  if uri.is_a?(String)
58
58
  uri = WebMock::Util::URI.normalize_uri(uri)
59
59
  end
60
+
60
61
  Config.instance.allow_net_connect ||
61
- (Config.instance.allow_localhost && WebMock::Util::URI.is_uri_localhost?(uri)) ||
62
- Config.instance.allow && (
63
- (Config.instance.allow.kind_of?(Regexp) && uri.to_s =~ Config.instance.allow) ||
64
- (Config.instance.allow.respond_to?(:include?) &&
65
- Config.instance.allow.include?(uri.host) || Config.instance.allow.include?("#{uri.host}:#{uri.port}")))
62
+ (
63
+ Config.instance.allow_localhost && WebMock::Util::URI.is_uri_localhost?(uri)) ||
64
+ Config.instance.allow && (
65
+ (Config.instance.allow.kind_of?(Regexp) && uri.to_s =~ Config.instance.allow) ||
66
+ (
67
+ Config.instance.allow.respond_to?(:include?) &&
68
+ (
69
+ Config.instance.allow.include?(uri.host) ||
70
+ Config.instance.allow.include?("#{uri.host}:#{uri.port}")
71
+ )
72
+ )
73
+ )
66
74
  end
67
75
 
68
76
  def self.reset!
@@ -105,10 +113,10 @@ module WebMock
105
113
  registered_request?
106
114
  ).each do |method|
107
115
  self.class_eval(%Q(
108
- def #{method}(*args, &block)
109
- WebMock::Deprecation.warning("WebMock##{method} instance method is deprecated. Please use WebMock.#{method} class method instead")
110
- WebMock.#{method}(*args, &block)
111
- end
116
+ def #{method}(*args, &block)
117
+ WebMock::Deprecation.warning("WebMock##{method} instance method is deprecated. Please use WebMock.#{method} class method instead")
118
+ WebMock.#{method}(*args, &block)
119
+ end
112
120
  ))
113
121
  end
114
122
 
@@ -238,12 +238,14 @@ shared_context "declared responses" do |*adapter_info|
238
238
  end
239
239
 
240
240
  describe "when response is declared as an Rack app" do
241
- before(:each) do
241
+ it "should return response returned by the rack app" do
242
242
  stub_request(:any, "http://www.example.com/greet").to_rack(MyRackApp)
243
+ http_request(:post, 'http://www.example.com/greet', :body => 'name=Jimmy').body.should == 'Good to meet you, Jimmy!'
243
244
  end
244
245
 
245
- it "should return response returned by the rack app" do
246
- http_request(:post, 'http://www.example.com/greet', :body => 'name=Jimmy').body.should == 'Good to meet you, Jimmy!'
246
+ it "should pass along the port number to the rack app" do
247
+ stub_request(:get, "http://www.example.com/compute").to_rack(MyRackApp)
248
+ http_request(:get, "http://www.example.com/compute").status.should == "200"
247
249
  end
248
250
  end
249
251
 
@@ -26,6 +26,12 @@ class MyRackApp
26
26
  when ['POST', '/greet']
27
27
  name = env["rack.input"].read[/name=([^&]*)/, 1] || "World"
28
28
  [200, {}, ["Good to meet you, #{name}!"]]
29
+ when ['GET', '/compute']
30
+ if env['SERVER_PORT'] == 80
31
+ [200, {}, [""]]
32
+ else
33
+ [401, {}, [""]]
34
+ end
29
35
  else
30
36
  [404, {}, ['']]
31
37
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 8
9
- - 5
10
- version: 1.8.5
9
+ - 6
10
+ version: 1.8.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bartosz Blimke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-30 00:00:00 Z
18
+ date: 2012-04-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: addressable