Skip to content

Commit e177697

Browse files
committed
Simplify error handling tests a bit
1 parent 1d566d1 commit e177697

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

spec/android_generate_apk_from_aab_spec.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,38 +122,35 @@ def expect_bundletool_call(aab, apk, *options)
122122
describe 'error handling' do
123123
it 'errors if bundletool is not installed' do
124124
allow(Fastlane::Action).to receive('sh').with('command', '-v', 'bundletool', any_args).and_raise
125-
expect(Fastlane::UI).to receive(:user_error!).with(described_class::MISSING_BUNDLETOOL_ERROR_MESSAGE).and_raise
126125

127126
expect do
128127
run_described_fastlane_action(
129128
aab_file_path: aab_file_path,
130129
apk_output_file_path: apk_output_file_path
131130
)
132-
end.to raise_error(RuntimeError)
131+
end.to raise_error(FastlaneCore::Interface::FastlaneError, described_class::MISSING_BUNDLETOOL_ERROR_MESSAGE)
133132
end
134133

135134
it 'errors if no input AAB file was provided nor can be inferred' do
136135
expect(Fastlane::Action).to receive('sh').with('command', '-v', 'bundletool', any_args)
137-
expect(Fastlane::UI).to receive(:user_error!).with(described_class::NO_AAB_ERROR_MESSAGE).and_raise
138136

139137
expect do
140138
run_described_fastlane_action(
141139
apk_output_file_path: apk_output_file_path
142140
)
143-
end.to raise_error(RuntimeError)
141+
end.to raise_error(FastlaneCore::Interface::FastlaneError, described_class::NO_AAB_ERROR_MESSAGE)
144142
end
145143

146144
it 'errors if the provided input AAB file does not exist' do
147145
expect(Fastlane::Action).to receive('sh').with('command', '-v', 'bundletool', any_args)
148146
allow(File).to receive(:file?).with(aab_file_path).and_return(false)
149-
expect(Fastlane::UI).to receive(:user_error!).with("The file `#{aab_file_path}` was not found. Please provide a path to an existing file.").and_raise
150147

151148
expect do
152149
run_described_fastlane_action(
153150
aab_file_path: aab_file_path,
154151
apk_output_file_path: apk_output_file_path
155152
)
156-
end.to raise_error(RuntimeError)
153+
end.to raise_error(FastlaneCore::Interface::FastlaneError, "The file `#{aab_file_path}` was not found. Please provide a path to an existing file.")
157154
end
158155
end
159156
end

0 commit comments

Comments
 (0)