forked from flapjack/flapjack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathworker_options_spec.rb
83 lines (68 loc) · 2.26 KB
/
worker_options_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require 'rubygems'
$: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'lib/flapjack/cli/worker'
describe Flapjack::WorkerOptions do
before(:each) do
end
# beanstalk
it "should accept the location of a beanstalk queue in short form" do
args = %w(-b localhost)
options = Flapjack::WorkerOptions.parse(args)
options.host.should == "localhost"
end
it "should accept the location of a beanstalk queue in long form" do
args = %w(--beanstalk localhost)
options = Flapjack::WorkerOptions.parse(args)
options.host.should == "localhost"
end
it "should set a default beanstalk host" do
args = []
options = Flapjack::WorkerOptions.parse(args)
options.host.should == 'localhost'
end
# beanstalk port
it "should accept a specified beanstalk port in short form" do
args = %w(-b localhost -p 11340)
options = Flapjack::WorkerOptions.parse(args)
options.port.should == 11340
end
it "should accept a specified beanstalk port in long form" do
args = %w(-b localhost --port 11399)
options = Flapjack::WorkerOptions.parse(args)
options.port.should == 11399
end
it "should set a default beanstalk port" do
args = %w(-b localhost)
options = Flapjack::WorkerOptions.parse(args)
options.port.should == 11300
end
it "should accept a specified checks directory in short form" do
args = %w(-c /tmp)
options = Flapjack::WorkerOptions.parse(args)
options.checks_directory.should == "/tmp"
end
it "should accept a specified checks directory in long form" do
args = %w(--checks-directory /tmp)
options = Flapjack::WorkerOptions.parse(args)
options.checks_directory.should == "/tmp"
end
it "should set a default checks directory" do
args = []
options = Flapjack::WorkerOptions.parse(args)
options.checks_directory.should_not be_nil
end
# general
it "should exit on when asked for help in short form" do
args = %w(-h)
lambda {
Flapjack::WorkerOptions.parse(args)
}.should raise_error(SystemExit)
end
it "should exit on when asked for help in long form" do
args = %w(--help)
lambda {
Flapjack::WorkerOptions.parse(args)
}.should raise_error(SystemExit)
end
end
def puts(*args) ; end