http-double 0.1.4 → 0.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: ddce8846e2c8ee613e8336b12dd3e2cced6b74ec
4
- data.tar.gz: 98afcf85f9c18a20a6cd945cc4173c542bc4ac05
3
+ metadata.gz: 81b92890f6ab3d244353c676d76e4121fa31fed4
4
+ data.tar.gz: 82d3959338d38342f31a3dfc979679b02e24848d
5
5
  SHA512:
6
- metadata.gz: 80f9ffbf21b56afc917ab9838c7c72c9177e876a7ac662cbec011c6bfcd7cccf3f297f1d31f25d9846c2dd477b1511bfd92f4940f3e25c7d98794cf035a83613
7
- data.tar.gz: d7a006300cf53bdcbabbd08b54ff9ec709527df88a54141c4e44139b6ce816e33dbcbd134b0cea072ff03c9baf5547352cb453553f0e99903728a99749fe8d07
6
+ metadata.gz: 753daa964b3d97941360d8ade0c00895412a9eeec9470a064168031700b22b3b6b69dd4a9b195fb01af5d6e71fb6a2eb7530b9eb040edd34fb3a50c264bb29cc
7
+ data.tar.gz: 7af479a962599e6cae377ddb61419cf8fe88cc212f72592f99c2d98fafc5f420408b462e3e0c0e37bb0495bb175082e1a6c28ccee132a88a9ecabc741895ed66
@@ -22,9 +22,10 @@ module HttpDouble
22
22
 
23
23
  end
24
24
 
25
- def background(*args)
26
- thread = Thread.new{ foreground *args }
25
+ def background(addr, port, **args)
26
+ thread = Thread.new{ foreground addr, port, **args }
27
27
  thread.abort_on_exception = true
28
+ sleep 0.05 until test_background addr, port
28
29
  thread
29
30
  end
30
31
 
@@ -36,6 +37,20 @@ module HttpDouble
36
37
  @loggers ||= {}
37
38
  end
38
39
 
40
+ private
41
+
42
+ def test_background(addr, port)
43
+ begin
44
+ http = Net::HTTP.new addr, port
45
+ http.head '/'
46
+ true
47
+ rescue SystemCallError
48
+ false
49
+ rescue
50
+ true
51
+ end
52
+ end
53
+
39
54
  end
40
55
 
41
56
  not_found { [404, ''] }
@@ -1,3 +1,3 @@
1
1
  module HttpDouble
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-double
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil E. Pearson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 3.0.0.beta2
117
+ version: 3.0.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 3.0.0.beta2
124
+ version: 3.0.0
125
125
  description: Provides a simple way to double HTTP services, APIs etc, for testing.
126
126
  email:
127
127
  - neil@helium.net.au