Sha256: 4c3615a83e863731348de26dc92fec7088d3058756ae3c7419c37443b68e8425
Contents?: true
Size: 957 Bytes
Versions: 1
Compression:
Stored size: 957 Bytes
Contents
shared_examples_for 'API request' do before do FakeWeb.register_uri(:post, url, options) end context 'when successful' do let(:options) do { body: '{"foo":"bar"}', content_type: 'application/json', status: [201, 'Created'] } end it 'should request json at Github' do subject.fetch('foo') FakeWeb.last_request.content_type.should == 'application/json' end it 'should parse the body as JSON' do subject.fetch('foo').should == 'bar' end end context 'when not OK' do let(:options) { { body: '', status: [301, 'Redirect'] } } it 'should raise' do expect { subject.fetch('foo') }.to raise_error(Gista::RequestError) end end context 'when not authorized' do let(:options) { { body: '', status: [401, 'Not authorized'] } } it 'should raise' do expect { subject.fetch('foo') }.to raise_error(Gista::Unauthorized) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gista-1.0.0 | spec/support/api_request_examples.rb |