forked from licensee/licensed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli_test.rb
104 lines (86 loc) · 2.88 KB
/
cli_test.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# frozen_string_literal: true
require "test_helper"
describe "licensed" do
let (:root) { File.expand_path("../../", __FILE__) }
let (:config_path) { File.join(root, "test/fixtures/cli/.licensed.yml") }
before do
Dir.chdir root
end
describe "cache" do
it "exits 0" do
_, status = Open3.capture2 "bundle exec exe/licensed cache -c #{config_path}"
assert status.success?
end
it "exits 1 when a config file isn't found" do
Dir.mktmpdir do |dir|
Dir.chdir dir do
_, _, status = Open3.capture3 "bundle exec exe/licensed cache"
refute status.success?
end
end
end
it "accepts a path to a config file" do
out, = Open3.capture2 "bundle exec exe/licensed cache -c #{config_path}"
refute out =~ /Usage/i
out, = Open3.capture2 "bundle exec exe/licensed cache --config #{config_path}"
refute out =~ /Usage/i
end
end
describe "status" do
it "exits 1 when failing" do
_, _, status = Open3.capture3 "bundle exec exe/licensed status -c #{config_path}"
refute status.success?
end
it "exits 1 when a config file isn't found" do
Dir.mktmpdir do |dir|
Dir.chdir dir do
_, _, status = Open3.capture3 "bundle exec exe/licensed status"
refute status.success?
end
end
end
it "accepts a path to a config file" do
out, = Open3.capture2 "bundle exec exe/licensed status -c #{config_path}"
refute out =~ /Usage/i
out, = Open3.capture2 "bundle exec exe/licensed status --config #{config_path}"
refute out =~ /Usage/i
end
end
describe "list" do
it "exits 0" do
_, status = Open3.capture2 "bundle exec exe/licensed list -c #{config_path}"
assert status.success?
end
it "exits 1 when a config file isn't found" do
Dir.mktmpdir do |dir|
Dir.chdir dir do
_, _, status = Open3.capture3 "bundle exec exe/licensed list"
refute status.success?
end
end
end
it "accepts a path to a config file" do
out, = Open3.capture2 "bundle exec exe/licensed list -c #{config_path}"
refute out =~ /Usage/i
out, = Open3.capture2 "bundle exec exe/licensed list --config #{config_path}"
refute out =~ /Usage/i
end
end
describe "version" do
it "outputs VERSION constant" do
expected_out = "#{Licensed::VERSION}\n"
out, = Open3.capture2 "bundle exec exe/licensed version"
assert_equal out, expected_out
out, = Open3.capture2 "bundle exec exe/licensed -v"
assert_equal out, expected_out
out, = Open3.capture2 "bundle exec exe/licensed --version"
assert_equal out, expected_out
end
end
describe "missing subcommand" do
it "exits 1 when a subcommand isn't defined" do
_, _, status = Open3.capture3 "bundle exec exe/licensed verify"
refute status.success?
end
end
end