-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
spaceauth_spec.rb
52 lines (43 loc) 路 1.92 KB
/
spaceauth_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
require_relative 'tunes/tunes_stubbing'
require 'fastlane_core/clipboard'
describe Spaceship::SpaceauthRunner do
let(:user_cookie) { TunesStubbing.itc_read_fixture_file('spaceauth_cookie.yml') }
it 'uses all required cookies for fastlane session' do
if FastlaneCore::Helper.mac?
expect(Spaceship::Client::UserInterface).to receive(:interactive?).and_return(false)
end
expect_any_instance_of(Spaceship::Client).to receive(:store_cookie).exactly(2).times.and_return(user_cookie)
expect do
Spaceship::SpaceauthRunner.new.run
end.to output(/export FASTLANE_SESSION=.*name: DES.*name: myacinfo.*name: dqsid.*/).to_stdout
end
describe 'copy_to_clipboard option', if: FastlaneCore::Clipboard.is_supported? do
before :each do
# Save clipboard
@clipboard = FastlaneCore::Clipboard.paste
end
after :each do
# Restore clipboard
FastlaneCore::Clipboard.copy(content: @clipboard)
end
it 'when true, it should copy the session to clipboard' do
Spaceship::SpaceauthRunner.new(copy_to_clipboard: true).run
expect(FastlaneCore::Clipboard.paste).to match(%r{.*domain: idmsa.apple.com.*path: \"\/appleauth\/auth\/\".*})
end
it 'when false, it should not copy the session to clipboard' do
Spaceship::SpaceauthRunner.new(copy_to_clipboard: false).run
expect(FastlaneCore::Clipboard.paste).to eq(@clipboard)
end
end
describe '#session_string' do
it 'should return the session when called after run' do
expect(Spaceship::SpaceauthRunner.new.run.session_string).to match(%r{.*domain: idmsa.apple.com.*path: \"\/appleauth\/auth\/\".*})
end
it 'should throw when called before run' do
expect(FastlaneCore::UI).to receive(:user_error!).with(/method called before calling `run` in `SpaceauthRunner`/).and_raise("boom")
expect do
Spaceship::SpaceauthRunner.new.session_string
end.to raise_error("boom")
end
end
end