lbspec 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/lbspec/respond.rb +7 -17
- data/lib/lbspec/transfer.rb +8 -17
- data/lib/lbspec/util.rb +8 -0
- data/lib/lbspec/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -31,7 +31,7 @@ You can use following chains with `#transfer`.
|
|
31
31
|
- port
|
32
32
|
- Tests if a virtual host transfers requests to specified port on target nodes.
|
33
33
|
- include
|
34
|
-
- Tests if a virtual host
|
34
|
+
- Tests if requests a virtual host transferred include string or are matched with regular expression.
|
35
35
|
- tcp
|
36
36
|
- Tests with tcp packets for the virtual host.
|
37
37
|
- udp
|
@@ -50,6 +50,7 @@ You can use following chains with `#transfer`.
|
|
50
50
|
|
51
51
|
### #respond
|
52
52
|
`#respond` tests if a virtual host on a load balancer respond as same as expected.
|
53
|
+
You can use both a string and a regular expression as a expectation.
|
53
54
|
|
54
55
|
#### chains
|
55
56
|
You can use following chains with `#respond`.
|
data/lib/lbspec/respond.rb
CHANGED
@@ -5,16 +5,6 @@ require 'rspec/expectations'
|
|
5
5
|
require 'lbspec'
|
6
6
|
|
7
7
|
RSpec::Matchers.define :respond do |expect|
|
8
|
-
|
9
|
-
@expect = expect
|
10
|
-
@protocol = :tcp
|
11
|
-
@application = nil
|
12
|
-
@path = nil
|
13
|
-
@string = nil
|
14
|
-
@chain_str = ''
|
15
|
-
@options = {}
|
16
|
-
@output_request = ''
|
17
|
-
|
18
8
|
match do |vhost|
|
19
9
|
request =
|
20
10
|
Lbspec::Request.new(vhost, @from,
|
@@ -27,40 +17,40 @@ RSpec::Matchers.define :respond do |expect|
|
|
27
17
|
chain :tcp do
|
28
18
|
@protocol = :tcp
|
29
19
|
@application = nil
|
30
|
-
@chain_str
|
20
|
+
Lbspec::Util.add_string(@chain_str, ' tcp')
|
31
21
|
end
|
32
22
|
|
33
23
|
chain :udp do
|
34
24
|
@protocol = :udp
|
35
25
|
@application = nil
|
36
|
-
@chain_str
|
26
|
+
Lbspec::Util.add_string(@chain_str, ' udp')
|
37
27
|
end
|
38
28
|
|
39
29
|
chain :http do
|
40
30
|
@protocol = :tcp
|
41
31
|
@application = :http
|
42
|
-
@chain_str
|
32
|
+
Lbspec::Util.add_string(@chain_str, ' http')
|
43
33
|
end
|
44
34
|
|
45
35
|
chain :https do
|
46
36
|
@protocol = :tcp
|
47
37
|
@application = :https
|
48
|
-
@chain_str
|
38
|
+
Lbspec::Util.add_string(@chain_str, ' https')
|
49
39
|
end
|
50
40
|
|
51
41
|
chain :from do |from|
|
52
42
|
@from = from
|
53
|
-
@chain_str
|
43
|
+
Lbspec::Util.add_string(@chain_str, " from #{from}")
|
54
44
|
end
|
55
45
|
|
56
46
|
chain :path do |path|
|
57
47
|
@path = path
|
58
|
-
@chain_str
|
48
|
+
Lbspec::Util.add_string(@chain_str, " via #{path}")
|
59
49
|
end
|
60
50
|
|
61
51
|
chain :with do |string|
|
62
52
|
@string = string
|
63
|
-
@chain_str
|
53
|
+
Lbspec::Util.add_string(@chain_str, " via #{string}")
|
64
54
|
end
|
65
55
|
|
66
56
|
chain :options do |options|
|
data/lib/lbspec/transfer.rb
CHANGED
@@ -5,15 +5,6 @@ require 'rspec/expectations'
|
|
5
5
|
require 'lbspec'
|
6
6
|
|
7
7
|
RSpec::Matchers.define :transfer do |nodes|
|
8
|
-
|
9
|
-
@include_str = nil
|
10
|
-
@port = 0
|
11
|
-
@path = nil
|
12
|
-
@chain_str = ''
|
13
|
-
@options = {}
|
14
|
-
@output_request = ''
|
15
|
-
@output_capture = ''
|
16
|
-
|
17
8
|
match do |vhost|
|
18
9
|
prove = Lbspec::Util.create_prove
|
19
10
|
capture =
|
@@ -31,44 +22,44 @@ RSpec::Matchers.define :transfer do |nodes|
|
|
31
22
|
|
32
23
|
chain :port do |port|
|
33
24
|
@port = port
|
34
|
-
@chain_str
|
25
|
+
Lbspec::Util.add_string(@chain_str, " port #{port}")
|
35
26
|
end
|
36
27
|
|
37
28
|
chain :tcp do
|
38
29
|
@protocol = :tcp
|
39
|
-
@chain_str
|
30
|
+
Lbspec::Util.add_string(@chain_str, ' tcp')
|
40
31
|
end
|
41
32
|
|
42
33
|
chain :udp do
|
43
34
|
@protocol = :udp
|
44
|
-
@chain_str
|
35
|
+
Lbspec::Util.add_string(@chain_str, ' udp')
|
45
36
|
end
|
46
37
|
|
47
38
|
chain :http do
|
48
39
|
@protocol = :tcp
|
49
40
|
@application = :http
|
50
|
-
@chain_str
|
41
|
+
Lbspec::Util.add_string(@chain_str, ' http')
|
51
42
|
end
|
52
43
|
|
53
44
|
chain :https do
|
54
45
|
@protocol = :tcp
|
55
46
|
@application = :https
|
56
|
-
@chain_str
|
47
|
+
Lbspec::Util.add_string(@chain_str, ' https')
|
57
48
|
end
|
58
49
|
|
59
50
|
chain :from do |from|
|
60
51
|
@from = from
|
61
|
-
@chain_str
|
52
|
+
Lbspec::Util.add_string(@chain_str, " from #{from}")
|
62
53
|
end
|
63
54
|
|
64
55
|
chain :include do |str|
|
65
56
|
@include_str = str
|
66
|
-
@chain_str
|
57
|
+
Lbspec::Util.add_string(@chain_str, " including #{str}")
|
67
58
|
end
|
68
59
|
|
69
60
|
chain :path do |path|
|
70
61
|
@path = path
|
71
|
-
@chain_str
|
62
|
+
Lbspec::Util.add_string(@chain_str, " via #{path}")
|
72
63
|
end
|
73
64
|
|
74
65
|
chain :options do |options|
|
data/lib/lbspec/util.rb
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
module Lbspec
|
4
4
|
# Lbspec::Util provides some utilities
|
5
5
|
class Util
|
6
|
+
def self.add_string(target, addition)
|
7
|
+
if target.nil?
|
8
|
+
target = addition
|
9
|
+
else
|
10
|
+
target << addition
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
6
14
|
def self.create_prove
|
7
15
|
t = Time.now
|
8
16
|
t.to_i.to_s + t.nsec.to_s
|
data/lib/lbspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lbspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -188,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
188
|
version: '0'
|
189
189
|
segments:
|
190
190
|
- 0
|
191
|
-
hash:
|
191
|
+
hash: -1779935330635841208
|
192
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
193
|
none: false
|
194
194
|
requirements:
|
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: '0'
|
198
198
|
segments:
|
199
199
|
- 0
|
200
|
-
hash:
|
200
|
+
hash: -1779935330635841208
|
201
201
|
requirements: []
|
202
202
|
rubyforge_project:
|
203
203
|
rubygems_version: 1.8.21
|