can upload file to datagouv
This commit is contained in:
parent
f7226ac625
commit
77a9a2ba12
2 changed files with 75 additions and 0 deletions
28
spec/lib/api_datagouv/api_spec.rb
Normal file
28
spec/lib/api_datagouv/api_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
describe APIDatagouv::API do
|
||||
describe '#upload' do
|
||||
let(:subject) { APIDatagouv::API.upload(Tempfile.new.path) }
|
||||
|
||||
before do
|
||||
stub_request(:post, /https:\/\/www.data.gouv.fr\/api/)
|
||||
.to_return(body: body, status: status)
|
||||
end
|
||||
|
||||
context "when response ok" do
|
||||
let(:status) { 200 }
|
||||
let(:body) { "ok" }
|
||||
|
||||
it 'returns body response' do
|
||||
expect(subject).to eq body
|
||||
end
|
||||
end
|
||||
|
||||
context "when responds with error" do
|
||||
let(:status) { 400 }
|
||||
let(:body) { "oops ! There is a problem..." }
|
||||
|
||||
it 'raise error' do
|
||||
expect { subject }.to raise_error(APIDatagouv::API::RequestFailed)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue