graphlient 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +0,0 @@
1
- module Graphlient
2
- module Errors
3
- class HTTP < Error
4
- attr_reader :response
5
-
6
- def initialize(message, response = nil)
7
- @response = response
8
- super message
9
- end
10
- end
11
- end
12
- end
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Graphlient::Client do
4
- let(:graphql_endpoint) { 'http://graph.biz/gprahql' }
5
- let(:request_headers) do
6
- {
7
- 'Authorization' => 'Bearer 1231',
8
- 'Content-Type' => 'application/json'
9
- }
10
- end
11
- let(:graphql_client) { Graphlient::Client.new(graphql_endpoint, headers: request_headers) }
12
- describe '#query' do
13
- let(:response) do
14
- graphql_client.query do
15
- invoice(id: 10) do
16
- line_items
17
- end
18
- end
19
- end
20
- describe 'success' do
21
- let!(:graphql_post_request) { stub_request(:post, 'http://graph.biz/gprahql').to_return(body: {}.to_json) }
22
- it 'returns expected query with block' do
23
- expect(response).to eq({})
24
- expect(graphql_post_request.with(
25
- body: { query: "{ \ninvoice(id: 10){\n line_items\n }\n }" },
26
- headers: { 'Content-Type' => 'application/json' }
27
- )).to have_been_made.once
28
- end
29
- end
30
- describe 'failure' do
31
- let!(:graphql_post_request) { stub_request(:post, 'http://graph.biz/gprahql').to_return(status: [500, 'Internal Server Error']) }
32
- it 'fails with an exception' do
33
- expect do
34
- response
35
- end.to raise_error Graphlient::Errors::HTTP do |e|
36
- expect(e.to_s).to eq 'Internal Server Error'
37
- expect(e.response.code.to_i).to eq 500
38
- end
39
- end
40
- end
41
- end
42
- end