glebtv-httpclient 3.2.7 → 3.2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -87,7 +87,7 @@ describe 'KeepAlive' do
87
87
  (0...10).to_a.map {
88
88
  Thread.new {
89
89
  Thread.abort_on_exception = true
90
- client.get(endpoint).content.should eq "12345"
90
+ expect(client.get(endpoint).content).to eq "12345"
91
91
  }
92
92
  }.each { |th| th.join }
93
93
  # send 5 requests, which should get KeepAliveDesconnected.
@@ -95,14 +95,14 @@ describe 'KeepAlive' do
95
95
  (0...5).to_a.map {
96
96
  Thread.new {
97
97
  Thread.abort_on_exception = true
98
- client.get(endpoint).content.should eq "23456"
98
+ expect(client.get(endpoint).content).to eq "23456"
99
99
  }
100
100
  }.each { |th| th.join }
101
101
  # rest requests won't get KeepAliveDisconnected; how can I check this?
102
102
  (0...10).to_a.map {
103
103
  Thread.new {
104
104
  Thread.abort_on_exception = true
105
- client.get(endpoint).content.should eq "34567"
105
+ expect(client.get(endpoint).content).to eq "34567"
106
106
  }
107
107
  }.each { |th| th.join }
108
108
  end
@@ -118,11 +118,11 @@ describe 'KeepAlive' do
118
118
  url = "http://127.0.0.1:#{server.addr[1]}/"
119
119
  # content-length
120
120
  5.times do
121
- client.get(url).body.should eq '12345'
121
+ expect(client.get(url).body).to eq '12345'
122
122
  end
123
123
  # chunked
124
124
  5.times do
125
- client.get(url + 'chunked').body.should eq 'abcdefghijklmnopqrstuvwxyz1234567890abcdef'
125
+ expect(client.get(url + 'chunked').body).to eq 'abcdefghijklmnopqrstuvwxyz1234567890abcdef'
126
126
  end
127
127
  server_thread.join
128
128
  end
data/spec/lru_spec.rb CHANGED
@@ -3,20 +3,14 @@ require 'spec_helper'
3
3
 
4
4
  describe HTTPClient::LRUCache do
5
5
  before :each do
6
- @cache = subject.class.new(ttl: 3, max_size: 2, soft_ttl: 2)
6
+ @cache = subject.class.new(ttl: 1, max_size: 2, soft_ttl: 2)
7
7
  end
8
8
 
9
9
  it 'expires values' do
10
- @cache.fetch 'test' do
11
- 2
12
- end.should eq 2
13
- @cache.fetch 'test' do
14
- 3
15
- end.should eq 2
16
- sleep 4
17
- @cache.fetch 'test' do
18
- 4
19
- end.should eq 4
10
+ expect(@cache.fetch('test') { 2 }).to eq(2)
11
+ expect(@cache.fetch('test') { 3 }).to eq(2)
12
+ sleep 2
13
+ expect(@cache.fetch('test') { 4 }).to eq(4)
20
14
  end
21
15
  end
22
16
 
data/test/test_auth.rb CHANGED
@@ -110,7 +110,6 @@ class TestAuth < Test::Unit::TestCase
110
110
  def test_BASIC_auth
111
111
  c = HTTPClient.new
112
112
  webrick_backup = @basic_auth.instance_eval { @auth_scheme }
113
- #httpaccess2_backup = c.www_auth.basic_auth.instance_eval { @scheme }
114
113
  begin
115
114
  @basic_auth.instance_eval { @auth_scheme = "BASIC" }
116
115
  c.www_auth.basic_auth.instance_eval { @scheme = "BASIC" }
@@ -118,7 +117,35 @@ class TestAuth < Test::Unit::TestCase
118
117
  assert_equal('basic_auth OK', c.get_content("http://localhost:#{serverport}/basic_auth"))
119
118
  ensure
120
119
  @basic_auth.instance_eval { @auth_scheme = webrick_backup }
121
- #c.www_auth.basic_auth.instance_eval { @scheme = httpaccess2_backup }
120
+ end
121
+ end
122
+
123
+ # To work this test consistently on CRuby you can to add 'Thread.pass' in
124
+ # @challenge iteration at BasicAuth#get like;
125
+ #
126
+ # return nil unless @challenge.find { |uri, ok|
127
+ # Thread.pass
128
+ # Util.uri_part_of(target_uri, uri) and ok
129
+ # }
130
+ def test_BASIC_auth_multi_thread
131
+ c = HTTPClient.new
132
+ webrick_backup = @basic_auth.instance_eval { @auth_scheme }
133
+ begin
134
+ @basic_auth.instance_eval { @auth_scheme = "BASIC" }
135
+ c.www_auth.basic_auth.instance_eval { @scheme = "BASIC" }
136
+ c.set_auth("http://localhost:#{serverport}/", 'admin', 'admin')
137
+
138
+ threads = 100.times.map { |idx|
139
+ Thread.new(idx) { |idx2|
140
+ Thread.abort_on_exception = true
141
+ Thread.pass
142
+ c.get("http://localhost:#{serverport}/basic_auth?#{idx2}")
143
+ }
144
+ }.map { |t|
145
+ t.join
146
+ }
147
+ ensure
148
+ @basic_auth.instance_eval { @auth_scheme = webrick_backup }
122
149
  end
123
150
  end
124
151
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glebtv-httpclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.7
4
+ version: 3.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-19 00:00:00.000000000 Z
12
+ date: 2014-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lru_redux
@@ -53,20 +53,6 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: test-unit
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: rspec
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -123,20 +109,6 @@ dependencies:
123
109
  - - ">="
124
110
  - !ruby/object:Gem::Version
125
111
  version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: rspecify
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: '0'
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: '0'
140
112
  description:
141
113
  email: glebtv@gmail.com
142
114
  executables: