vanagon 0.15.38 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,64 +0,0 @@
1
- require 'vanagon/optparse'
2
-
3
- describe Vanagon::OptParse do
4
-
5
- describe "options that don't take a value" do
6
- [:skipcheck, :verbose].each do |flag|
7
- it "can create an option parser that accepts the #{flag} flag" do
8
- subject = described_class.new("test", [flag])
9
- expect(subject.parse!(["--#{flag}"])).to have_key(flag)
10
- end
11
- end
12
-
13
- describe "short options" do
14
- [["v", :verbose]].each do |short, long|
15
- it "maps the short option #{short} to #{long}" do
16
- subject = described_class.new("test", [long])
17
- expect(subject.parse!(["-#{short}"])).to include(long => true)
18
- end
19
- end
20
- end
21
- end
22
-
23
- describe "options that only allow limited values" do
24
- [[:preserve, ["always", "never", "on-failure"]]].each do |option, values|
25
- values.each do |value|
26
- it "can create a parser that accepts \"--#{option} #{value}\"" do
27
- subject = described_class.new("test", [option, value])
28
- expect(subject.parse!(["--#{option}", value])).to eq(option => value.to_sym)
29
- end
30
- end
31
- end
32
- [[:preserve, ["bad-argument"]]].each do |option, values|
33
- values.each do |value|
34
- it "rejects the bad argument \"--#{option} #{value}\"" do
35
- subject = described_class.new("test", [option, value])
36
- expect{subject.parse!(["--#{option}", value])}.to raise_error(OptionParser::InvalidArgument)
37
- end
38
- end
39
- end
40
- it "preserve defaults to :on-failure" do
41
- subject = described_class.new("test")
42
- expect(subject.parse!([])).to include(:preserve => :'on-failure')
43
- end
44
- end
45
-
46
-
47
- describe "options that take a value" do
48
- [:workdir, :configdir, :engine].each do |option|
49
- it "can create an option parser that accepts the #{option} option" do
50
- subject = described_class.new("test", [option])
51
- expect(subject.parse!(["--#{option}", "hello"])).to include(option => "hello")
52
- end
53
- end
54
-
55
- describe "short options" do
56
- [["w", :workdir], ["c", :configdir], ["e", :engine]].each do |short, long|
57
- it "maps the short option #{short} to #{long}" do
58
- subject = described_class.new("test", [long])
59
- expect(subject.parse!(["-#{short}", "hello"])).to include(long => "hello")
60
- end
61
- end
62
- end
63
- end
64
- end