-
Notifications
You must be signed in to change notification settings - Fork 245
/
Copy pathinstall_spec.rb
62 lines (54 loc) · 2.76 KB
/
install_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
require File.expand_path('../spec_helper', __FILE__)
module XcodeInstall
describe Command::Install do
describe 'when invoked' do
before do
Installer.any_instance.stubs(:exists).returns(true)
Installer.any_instance.stubs(:installed).returns([])
fixture = Pathname.new('spec/fixtures/xcode_63.json').read
xcode = Xcode.new(JSON.parse(fixture))
Installer.any_instance.stubs(:seedlist).returns([xcode])
end
it 'downloads and installs' do
Installer.any_instance.expects(:download).with('6.3', true, nil, nil, 3).returns('/some/path')
Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
Command::Install.run(['6.3'])
end
it 'downloads and installs with custom HTTP URL' do
url = 'http://yolo.com/xcode.dmg'
Installer.any_instance.expects(:download).with('6.3', true, url, nil, 3).returns('/some/path')
Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
Command::Install.run(['6.3', "--url=#{url}"])
end
it 'downloads and installs and does not switch if --no-switch given' do
Installer.any_instance.expects(:download).with('6.3', true, nil, nil, 3).returns('/some/path')
Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', false, true)
Command::Install.run(['6.3', '--no-switch'])
end
it 'downloads without progress if switch --no-progress is given' do
Installer.any_instance.expects(:download).with('6.3', false, nil, nil, 3).returns('/some/path')
Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
Command::Install.run(['6.3', '--no-progress'])
end
it 'reads .xcode-version' do
Installer.any_instance.expects(:download).with('6.3', true, nil, nil, 3).returns('/some/path')
Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
File.expects(:exist?).with('.xcode-version').returns(true)
File.expects(:read).returns('6.3')
Command::Install.run([])
end
end
it 'parses hdiutil output' do
installer = Installer.new
fixture = Pathname.new('spec/fixtures/hdiutil.plist').read
installer.expects(:hdiutil).with('mount', '-plist', '-nobrowse', '-noverify', '/some/path').returns(fixture)
location = installer.send(:mount, Pathname.new('/some/path'))
location.should == '/Volumes/XcodeME'
end
it 'gives more helpful error when downloaded DMG turns out to be HTML' do
installer = Installer.new
should.raise(Informative) { installer.mount('spec/fixtures/mail-verify.html') }.message
.should.include 'logging into your account from a browser'
end
end
end