|
|
@@ -8,9 +8,9 @@ RSpec.describe PKParse::Client do
|
|
|
|
|
|
before { allow(RestClient).to receive(:post).and_return(response) }
|
|
|
|
|
|
- describe '#parse' do
|
|
|
+ describe '#parse_files' do
|
|
|
let!(:files) { [] }
|
|
|
- subject { client.parse(files) }
|
|
|
+ subject { client.parse_files(files) }
|
|
|
|
|
|
context 'succeeds as normal' do
|
|
|
specify { expect(subject.pokemon.size).to eq 1 }
|
|
|
@@ -33,4 +33,31 @@ RSpec.describe PKParse::Client do
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
+
|
|
|
+ describe '#parse_base64' do
|
|
|
+ let!(:base64_strings) { ['dead'] }
|
|
|
+ subject { client.parse_base64(base64_strings) }
|
|
|
+
|
|
|
+ context 'succeeds as normal' do
|
|
|
+ specify { expect(subject.pokemon.size).to eq 1 }
|
|
|
+ end
|
|
|
+
|
|
|
+ context 'fails' do
|
|
|
+ context 'getting a response' do
|
|
|
+ before { allow(RestClient).to receive(:post).and_raise(RestClient::Exception.new) }
|
|
|
+
|
|
|
+ it 'returns a more specific error' do
|
|
|
+ expect { subject }.to raise_error(PKParse::ResponseError)
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ context 'processing a response' do
|
|
|
+ before { allow(JSON).to receive(:parse).and_raise(JSON::ParserError.new) }
|
|
|
+
|
|
|
+ it 'returns a more specific error' do
|
|
|
+ expect { subject }.to raise_error(PKParse::Error)
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
end
|