-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathutils_spec.rb
84 lines (70 loc) · 2.26 KB
/
utils_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
84
require 'spec_helper'
require 'fpm/cookery/utils'
describe FPM::Cookery::Utils do
class TestUtils
include FPM::Cookery::Utils
def run_configure_no_arg
configure
end
def run_configure
configure '--prefix=/usr', '--test=yo'
end
def run_configure_hash
configure :hello_world => true, :prefix => '/usr', 'a-dash' => 1
end
def run_configure_mix
configure '--first=okay', '--second=okay', :hello_world => true, :prefix => '/usr', 'a-dash' => 1
end
def run_go_build
go 'build', '-mod=vendor', '-v'
end
def run_go_build_hash
go :build, :mod => 'vendor', :v => true
end
end
let(:test) { TestUtils.new }
before do
# Avoid shellout.
allow(test).to receive(:system).and_return('success')
end
describe '#configure' do
context 'with a list of string arguments' do
it 'calls ./configure with the correct arguments' do
expect(test).to receive(:system).with('./configure', '--prefix=/usr', '--test=yo')
test.run_configure
end
end
context 'with hash arguments' do
it 'calls ./configure with the correct arguments' do
expect(test).to receive(:system).with('./configure', '--hello-world', '--prefix=/usr', '--a-dash=1')
test.run_configure_hash
end
end
context 'with string and hash arguments' do
it 'calls ./configure with the correct arguments' do
expect(test).to receive(:system).with('./configure', '--first=okay', '--second=okay', '--hello-world', '--prefix=/usr', '--a-dash=1')
test.run_configure_mix
end
end
context 'without any arguments' do
it 'calls ./configure without any arguments' do
expect(test).to receive(:system).with('./configure')
test.run_configure_no_arg
end
end
end
describe '#go' do
context 'with a list of string arguments' do
it 'calls go with the correct arguments' do
expect(test).to receive(:system).with('go', 'build', '-mod=vendor', '-v')
test.run_go_build
end
end
context 'with hash arguments' do
it 'calls go with the correct arguments' do
expect(test).to receive(:system).with('go', 'build', '--mod=vendor', '--v')
test.run_go_build_hash
end
end
end
end