igp 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +34 -0
- data/.gitignore +56 -0
- data/.rubocop.yml +35 -0
- data/.rubocop_todo.yml +86 -0
- data/CHANGELOG +13 -0
- data/Gemfile +2 -10
- data/Guardfile +16 -0
- data/README.rdoc +2 -0
- data/Rakefile +11 -46
- data/bin/igp +3 -4
- data/igp.gemspec +28 -71
- data/lib/igp/base.rb +40 -26
- data/lib/igp/shell.rb +38 -34
- data/lib/igp/version.rb +1 -1
- data/spec/base_spec.rb +45 -38
- data/spec/format_spec.rb +46 -0
- data/spec/shell_spec.rb +93 -94
- data/spec/spec_helper.rb +13 -0
- metadata +152 -96
- data/Gemfile.lock +0 -34
- data/init.rb +0 -1
data/lib/igp/shell.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'uri'
|
2
|
-
class Igp::Shell
|
3
2
|
|
3
|
+
# class that groks the igp command line options and invokes the ping task
|
4
|
+
class Igp::Shell
|
4
5
|
# holds the parsed options
|
5
6
|
attr_reader :options
|
6
7
|
# holds the URI object representing the ping target
|
@@ -12,12 +13,13 @@ class Igp::Shell
|
|
12
13
|
#
|
13
14
|
# +args+ is the remaining command line arguments
|
14
15
|
#
|
15
|
-
def initialize(options,args)
|
16
|
+
def initialize(options, args)
|
16
17
|
defaults = {
|
17
|
-
:
|
18
|
+
interval: 1
|
18
19
|
}
|
19
|
-
@options = defaults.merge(
|
20
|
+
@options = defaults.merge((options || {}).each { |k, v| { k => v } })
|
20
21
|
return unless args.first
|
22
|
+
|
21
23
|
resolve_addressing args.first
|
22
24
|
normalise_options
|
23
25
|
end
|
@@ -30,7 +32,7 @@ class Igp::Shell
|
|
30
32
|
unless uri.scheme
|
31
33
|
@options[:type] = :icmp
|
32
34
|
@options[:host] = uri.to_s
|
33
|
-
@options[:url] = "#{@options[:type]
|
35
|
+
@options[:url] = "#{@options[:type]}://#{@options[:host]}"
|
34
36
|
return
|
35
37
|
end
|
36
38
|
@options[:url] = uri.to_s
|
@@ -50,7 +52,8 @@ class Igp::Shell
|
|
50
52
|
# runs the ping task
|
51
53
|
def run
|
52
54
|
case options[:type]
|
53
|
-
|
55
|
+
# TODO: LDAP was retired from net-ping. to add back in one way or another
|
56
|
+
when :icmp, :http, :https, :tcp, :udp # :ldap, :ldaps
|
54
57
|
Igp::Base.new(options).run
|
55
58
|
else
|
56
59
|
usage
|
@@ -58,49 +61,50 @@ class Igp::Shell
|
|
58
61
|
end
|
59
62
|
|
60
63
|
# defines the valid command line options
|
61
|
-
OPTIONS = %w
|
64
|
+
OPTIONS = %w[help verbose interval=i limit=i].freeze
|
62
65
|
|
63
66
|
# prints usage/help information
|
64
67
|
def usage
|
65
68
|
self.class.usage
|
66
69
|
end
|
70
|
+
|
67
71
|
# prints usage/help information
|
68
72
|
def self.usage
|
69
|
-
$stderr.puts
|
73
|
+
$stderr.puts <<~EOS
|
70
74
|
|
71
|
-
It goes PING! v#{Igp::VERSION}
|
72
|
-
===================================
|
75
|
+
It goes PING! v#{Igp::VERSION}
|
76
|
+
===================================
|
73
77
|
|
74
|
-
Usage:
|
75
|
-
|
76
|
-
|
77
|
-
Options:
|
78
|
-
-h | --help :shows command help
|
79
|
-
-i= | --interval=seconds (default: 1 second)
|
80
|
-
-l= | --limit=number of tests (default: infinite)
|
78
|
+
Usage:
|
79
|
+
igp [options] uri
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
Options:
|
82
|
+
-h | --help :shows command help
|
83
|
+
-i= | --interval=seconds (default: 1 second)
|
84
|
+
-l= | --limit=number of tests (default: infinite)
|
85
85
|
|
86
|
-
|
86
|
+
The uri specifies the protocol, hostname and port.
|
87
|
+
The ICMP protocol is assumed if not specified.
|
88
|
+
The default well-known port is assumed if not specified.
|
87
89
|
|
88
|
-
|
89
|
-
igp localhost
|
90
|
-
igp icmp://localhost
|
90
|
+
Examples:
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
ICMP ping:
|
93
|
+
igp localhost
|
94
|
+
igp icmp://localhost
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
UDP/TCP ping:
|
97
|
+
igp udp://localhost:123
|
98
|
+
igp tcp://localhost:843
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
HTTP/S ping:
|
101
|
+
igp http://localhost:8080
|
102
|
+
igp https://localhost:4443
|
103
103
|
|
104
104
|
EOS
|
105
|
+
# TODO: LDAP was retired from net-ping. to add back in one way or another
|
106
|
+
# LDAP/S ping:
|
107
|
+
# igp ldap://localhost
|
108
|
+
# igp ldaps://localhost:6636
|
105
109
|
end
|
106
|
-
end
|
110
|
+
end
|
data/lib/igp/version.rb
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -2,58 +2,65 @@ require 'spec_helper'
|
|
2
2
|
require 'getoptions'
|
3
3
|
|
4
4
|
describe Igp::Base do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@base = Igp::Base.new
|
9
|
-
end
|
10
|
-
it "should not set ping_handler" do
|
11
|
-
@base.ping_handler.should be_nil
|
5
|
+
describe 'base initialization without options' do
|
6
|
+
it 'should not set ping_handler' do
|
7
|
+
expect(subject.ping_handler).to be_nil
|
12
8
|
end
|
13
|
-
it
|
14
|
-
|
9
|
+
it 'should not set limit' do
|
10
|
+
expect(subject.limit).to be_nil
|
15
11
|
end
|
16
|
-
it
|
17
|
-
|
12
|
+
it 'should default interval to 5 sec' do
|
13
|
+
expect(subject.interval).to eql(5)
|
18
14
|
end
|
19
15
|
end
|
20
|
-
|
21
|
-
describe
|
22
|
-
it
|
23
|
-
options = { :
|
16
|
+
|
17
|
+
describe 'ping_handler configuration' do
|
18
|
+
it 'should be Net::Ping::External for :icmp' do
|
19
|
+
options = { type: :icmp, host: 'localhost', port: nil }
|
24
20
|
base = Igp::Base.new(options)
|
25
|
-
base.ping_handler.
|
21
|
+
expect(base.ping_handler).to be_a(Net::Ping::External)
|
26
22
|
end
|
27
|
-
it
|
28
|
-
options = { :
|
23
|
+
it 'should be Net::Ping::UDP for :tcp' do
|
24
|
+
options = { type: :udp, host: 'localhost', port: 22 }
|
29
25
|
base = Igp::Base.new(options)
|
30
|
-
base.ping_handler.
|
26
|
+
expect(base.ping_handler).to be_a(Net::Ping::UDP)
|
31
27
|
end
|
32
|
-
it
|
33
|
-
options = { :
|
28
|
+
it 'should be Net::Ping::TCP for :tcp' do
|
29
|
+
options = { type: :tcp, host: 'localhost', port: 22 }
|
34
30
|
base = Igp::Base.new(options)
|
35
|
-
base.ping_handler.
|
31
|
+
expect(base.ping_handler).to be_a(Net::Ping::TCP)
|
36
32
|
end
|
37
|
-
it
|
38
|
-
options = { :
|
33
|
+
it 'should be Net::Ping::HTTP for :http' do
|
34
|
+
options = { type: :http, url: 'http://localhost' }
|
39
35
|
base = Igp::Base.new(options)
|
40
|
-
base.ping_handler.
|
36
|
+
expect(base.ping_handler).to be_a(Net::Ping::HTTP)
|
41
37
|
end
|
42
|
-
it
|
43
|
-
options = { :
|
38
|
+
it 'should be Net::Ping::HTTP for :https' do
|
39
|
+
options = { type: :https, url: 'https://localhost' }
|
44
40
|
base = Igp::Base.new(options)
|
45
|
-
base.ping_handler.
|
41
|
+
expect(base.ping_handler).to be_a(Net::Ping::HTTP)
|
46
42
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
43
|
+
# TODO: LDAP was retired from net-ping. to add back in one way or another
|
44
|
+
# it 'should be Net::Ping::LDAP for :ldap' do
|
45
|
+
# options = { type: :ldap, url: 'ldap://localhost' }
|
46
|
+
# base = Igp::Base.new(options)
|
47
|
+
# expect(base.ping_handler).to be_a(Net::Ping::LDAP)
|
48
|
+
# end
|
49
|
+
# it 'should be Net::Ping::LDAP for :ldaps' do
|
50
|
+
# options = { type: :ldaps, url: 'ldaps://localhost' }
|
51
|
+
# base = Igp::Base.new(options)
|
52
|
+
# expect(base.ping_handler).to be_a(Net::Ping::LDAP)
|
53
|
+
# end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#run' do
|
57
|
+
before do
|
58
|
+
@good = Igp::Base.new({ type: :icmp, host: 'localhost', port: nil, limit: 1 })
|
51
59
|
end
|
52
|
-
it
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
it 'should print header and log a ping result' do
|
61
|
+
expect(@good.formatter).to receive(:header)
|
62
|
+
expect(@good.formatter).to receive(:log)
|
63
|
+
capture(:stdout, :stderr) { @good.run }
|
56
64
|
end
|
57
65
|
end
|
58
|
-
|
59
|
-
end
|
66
|
+
end
|
data/spec/format_spec.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'getoptions'
|
3
|
+
|
4
|
+
describe Igp::Base::Format do
|
5
|
+
describe '#duration' do
|
6
|
+
it 'should return nil for nil duration' do
|
7
|
+
expect(subject.duration(nil)).to be_nil
|
8
|
+
end
|
9
|
+
it 'should return string to 6 decimal places for non-nil duration' do
|
10
|
+
result = subject.duration(1.0)
|
11
|
+
expect(result).to match(/^\d+\.\d{6}$/)
|
12
|
+
expect(result.to_f).to eql(1.0)
|
13
|
+
end
|
14
|
+
it 'should handle integer parameter' do
|
15
|
+
result = subject.duration(1)
|
16
|
+
expect(result).to match(/^\d+\.\d{6}$/)
|
17
|
+
expect(result.to_f).to eql(1.0)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#header' do
|
22
|
+
it 'should output a blank line for nil parameters' do
|
23
|
+
result = capture(:stderr) { subject.header(nil) }
|
24
|
+
expect(result).to eql("\n")
|
25
|
+
end
|
26
|
+
it 'should convert an arbitrary array of strings and numbers to a space-delimited output to stderr' do
|
27
|
+
result = capture(:stderr) { subject.header('string', 1.0, 'another string', 2.0) }
|
28
|
+
expect(result).to eql("string 1.0 another string 2.0\n")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#log' do
|
33
|
+
it 'should output time only for nil parameters' do
|
34
|
+
result = capture(:stdout) { subject.log(nil) }
|
35
|
+
expect(result).to match(/^.+Z,$/)
|
36
|
+
end
|
37
|
+
it 'should log successful message (boolean,float,nil) to stdout' do
|
38
|
+
result = capture(:stdout) { subject.log(true, 1.0, nil) }
|
39
|
+
expect(result).to match(/^.+Z,true,1.0,$/)
|
40
|
+
end
|
41
|
+
it 'should log unsuccessful message (boolean,nil,string) to stdout' do
|
42
|
+
result = capture(:stdout) { subject.log(false, nil, 'message') }
|
43
|
+
expect(result).to match(/^.+Z,false,,message$/)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/shell_spec.rb
CHANGED
@@ -2,22 +2,21 @@ require 'spec_helper'
|
|
2
2
|
require 'getoptions'
|
3
3
|
|
4
4
|
describe Igp::Shell do
|
5
|
-
|
6
|
-
describe "base configuration" do
|
5
|
+
describe 'base configuration' do
|
7
6
|
context 'without destination specified' do
|
8
7
|
before do
|
9
8
|
@options = GetOptions.new(Igp::Shell::OPTIONS, [])
|
10
9
|
end
|
11
|
-
it
|
12
|
-
expect { Igp::Shell.new(@options,[]) }.to_not raise_error
|
10
|
+
it 'should initialize without error' do
|
11
|
+
expect { Igp::Shell.new(@options, []) }.to_not raise_error
|
13
12
|
end
|
14
|
-
it
|
15
|
-
Igp::Shell.respond_to
|
16
|
-
Igp::Shell.new(@options,[]).respond_to
|
13
|
+
it 'should provide help/usage' do
|
14
|
+
expect(Igp::Shell).to respond_to(:usage)
|
15
|
+
expect(Igp::Shell.new(@options, [])).to respond_to(:usage)
|
17
16
|
end
|
18
|
-
it
|
19
|
-
shell = Igp::Shell.new(@options,[])
|
20
|
-
shell.
|
17
|
+
it 'should print usage when run' do
|
18
|
+
shell = Igp::Shell.new(@options, [])
|
19
|
+
expect(shell).to receive(:usage)
|
21
20
|
shell.run
|
22
21
|
end
|
23
22
|
end
|
@@ -25,137 +24,137 @@ describe Igp::Shell do
|
|
25
24
|
before do
|
26
25
|
@options_server_value = 'example.com'
|
27
26
|
@options = GetOptions.new(Igp::Shell::OPTIONS, [])
|
28
|
-
@shell = Igp::Shell.new(@options,[@options_server_value])
|
27
|
+
@shell = Igp::Shell.new(@options, [@options_server_value])
|
29
28
|
end
|
30
|
-
it
|
31
|
-
@shell.options[:interval].
|
32
|
-
@shell.options[:limit].
|
29
|
+
it 'should default to 1 second infinte intervals' do
|
30
|
+
expect(@shell.options[:interval]).to eql(1)
|
31
|
+
expect(@shell.options[:limit]).to be_nil
|
33
32
|
end
|
34
|
-
it
|
35
|
-
@shell.options[:host].
|
36
|
-
@shell.options[:type].
|
33
|
+
it 'should accept server and default to icmp ping' do
|
34
|
+
expect(@shell.options[:host]).to eql(@options_server_value)
|
35
|
+
expect(@shell.options[:type]).to eql(:icmp)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
40
|
-
|
41
|
-
describe
|
39
|
+
|
40
|
+
describe 'tcp configuration' do
|
42
41
|
before(:each) do
|
43
42
|
@type = :tcp
|
44
43
|
@host = 'localhost'
|
45
44
|
@port = 843
|
46
|
-
@options_server_value = "#{@type
|
45
|
+
@options_server_value = "#{@type}://#{@host}:#{@port}"
|
47
46
|
@shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value])
|
48
47
|
end
|
49
|
-
it
|
50
|
-
@shell.options[:url].
|
48
|
+
it 'should support url accessor' do
|
49
|
+
expect(@shell.options[:url]).to eql(@options_server_value)
|
51
50
|
end
|
52
|
-
it
|
53
|
-
@shell.options[:type].
|
51
|
+
it 'should default to tcp ping with url when given server with tcp protocol setting' do
|
52
|
+
expect(@shell.options[:type]).to eql(@type)
|
54
53
|
end
|
55
|
-
it
|
56
|
-
@shell.options[:host].
|
57
|
-
@shell.options[:port].
|
54
|
+
it 'should resolve host/port' do
|
55
|
+
expect(@shell.options[:host]).to eql(@host)
|
56
|
+
expect(@shell.options[:port]).to eql(@port)
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
|
-
describe
|
60
|
+
describe 'udp configuration' do
|
62
61
|
before(:each) do
|
63
62
|
@type = :udp
|
64
63
|
@host = 'localhost'
|
65
64
|
@port = 22
|
66
|
-
@options_server_value = "#{@type
|
65
|
+
@options_server_value = "#{@type}://#{@host}:#{@port}"
|
67
66
|
@shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value])
|
68
67
|
end
|
69
|
-
it
|
70
|
-
@shell.options[:url].
|
68
|
+
it 'should support url accessor' do
|
69
|
+
expect(@shell.options[:url]).to eql(@options_server_value)
|
71
70
|
end
|
72
|
-
it
|
73
|
-
@shell.options[:type].
|
71
|
+
it 'should default to tcp ping with url when given server with tcp protocol setting' do
|
72
|
+
expect(@shell.options[:type]).to eql(@type)
|
74
73
|
end
|
75
|
-
it
|
76
|
-
@shell.options[:host].
|
77
|
-
@shell.options[:port].
|
74
|
+
it 'should resolve host/port' do
|
75
|
+
expect(@shell.options[:host]).to eql(@host)
|
76
|
+
expect(@shell.options[:port]).to eql(@port)
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
81
|
-
describe
|
80
|
+
describe 'http configuration' do
|
82
81
|
before(:each) do
|
83
82
|
@type = :http
|
84
83
|
@host = 'localhost'
|
85
84
|
@port = 80
|
86
|
-
@options_server_value = "#{@type
|
85
|
+
@options_server_value = "#{@type}://#{@host}"
|
87
86
|
@shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value])
|
88
87
|
end
|
89
|
-
it
|
90
|
-
@shell.options[:url].
|
88
|
+
it 'should support url accessor' do
|
89
|
+
expect(@shell.options[:url]).to eql(@options_server_value)
|
91
90
|
end
|
92
|
-
it
|
93
|
-
@shell.options[:type].
|
91
|
+
it 'should default to tcp ping with url when given server with tcp protocol setting' do
|
92
|
+
expect(@shell.options[:type]).to eql(@type)
|
94
93
|
end
|
95
|
-
it
|
96
|
-
@shell.options[:host].
|
97
|
-
@shell.options[:port].
|
94
|
+
it 'should resolve host/port' do
|
95
|
+
expect(@shell.options[:host]).to eql(@host)
|
96
|
+
expect(@shell.options[:port]).to eql(@port)
|
98
97
|
end
|
99
98
|
end
|
100
99
|
|
101
|
-
describe
|
100
|
+
describe 'https configuration' do
|
102
101
|
before(:each) do
|
103
102
|
@type = :https
|
104
103
|
@host = 'localhost'
|
105
104
|
@port = 443
|
106
|
-
@options_server_value = "#{@type
|
105
|
+
@options_server_value = "#{@type}://#{@host}"
|
107
106
|
@shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value])
|
108
107
|
end
|
109
|
-
it
|
110
|
-
@shell.options[:url].
|
108
|
+
it 'should support url accessor' do
|
109
|
+
expect(@shell.options[:url]).to eql(@options_server_value)
|
111
110
|
end
|
112
|
-
it
|
113
|
-
@shell.options[:type].
|
111
|
+
it 'should default to tcp ping with url when given server with tcp protocol setting' do
|
112
|
+
expect(@shell.options[:type]).to eql(@type)
|
114
113
|
end
|
115
|
-
it
|
116
|
-
@shell.options[:host].
|
117
|
-
@shell.options[:port].
|
114
|
+
it 'should resolve host/port' do
|
115
|
+
expect(@shell.options[:host]).to eql(@host)
|
116
|
+
expect(@shell.options[:port]).to eql(@port)
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "ldaps configuration" do
|
142
|
-
before(:each) do
|
143
|
-
@type = :ldaps
|
144
|
-
@host = 'localhost'
|
145
|
-
@port = 636
|
146
|
-
@options_server_value = "#{@type.to_s}://#{@host}"
|
147
|
-
@shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value])
|
148
|
-
end
|
149
|
-
it "should support url accessor" do
|
150
|
-
@shell.options[:url].should eql(@options_server_value)
|
151
|
-
end
|
152
|
-
it "should default to tcp ping with url when given server with tcp protocol setting" do
|
153
|
-
@shell.options[:type].should eql(@type)
|
154
|
-
end
|
155
|
-
it "should resolve host/port" do
|
156
|
-
@shell.options[:host].should eql(@host)
|
157
|
-
@shell.options[:port].should eql(@port)
|
158
|
-
end
|
159
|
-
end
|
120
|
+
# TODO: LDAP was retired from net-ping. to add back in one way or another
|
121
|
+
# describe 'ldap configuration' do
|
122
|
+
# before(:each) do
|
123
|
+
# @type = :ldap
|
124
|
+
# @host = 'localhost'
|
125
|
+
# @port = 389
|
126
|
+
# @options_server_value = "#{@type}://#{@host}"
|
127
|
+
# @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value])
|
128
|
+
# end
|
129
|
+
# it 'should support url accessor' do
|
130
|
+
# expect(@shell.options[:url]).to eql(@options_server_value)
|
131
|
+
# end
|
132
|
+
# it 'should default to tcp ping with url when given server with tcp protocol setting' do
|
133
|
+
# expect(@shell.options[:type]).to eql(@type)
|
134
|
+
# end
|
135
|
+
# it 'should resolve host/port' do
|
136
|
+
# expect(@shell.options[:host]).to eql(@host)
|
137
|
+
# expect(@shell.options[:port]).to eql(@port)
|
138
|
+
# end
|
139
|
+
# end
|
160
140
|
|
161
|
-
|
141
|
+
# describe 'ldaps configuration' do
|
142
|
+
# before(:each) do
|
143
|
+
# @type = :ldaps
|
144
|
+
# @host = 'localhost'
|
145
|
+
# @port = 636
|
146
|
+
# @options_server_value = "#{@type}://#{@host}"
|
147
|
+
# @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value])
|
148
|
+
# end
|
149
|
+
# it 'should support url accessor' do
|
150
|
+
# expect(@shell.options[:url]).to eql(@options_server_value)
|
151
|
+
# end
|
152
|
+
# it 'should default to tcp ping with url when given server with tcp protocol setting' do
|
153
|
+
# expect(@shell.options[:type]).to eql(@type)
|
154
|
+
# end
|
155
|
+
# it 'should resolve host/port' do
|
156
|
+
# expect(@shell.options[:host]).to eql(@host)
|
157
|
+
# expect(@shell.options[:port]).to eql(@port)
|
158
|
+
# end
|
159
|
+
# end
|
160
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1,14 @@
|
|
1
1
|
require 'igp'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
def capture(*streams)
|
5
|
+
streams.map!(&:to_s)
|
6
|
+
begin
|
7
|
+
result = StringIO.new
|
8
|
+
streams.each { |stream| eval "$#{stream} = result # $#{stream} = result" }
|
9
|
+
yield
|
10
|
+
ensure
|
11
|
+
streams.each { |stream| eval("$#{stream} = #{stream.upcase} # $#{stream} = #{stream.upcase}") }
|
12
|
+
end
|
13
|
+
result.string
|
14
|
+
end
|