Sha256: a7c9f6401dd098450d5f5cde94ae028612a1ec392feea6cfd8f6000e86fbb55e

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Graphlient::Client do
  describe 'parse and execute' do
    module Graphlient::Client::Spec
      Client = Graphlient::Client.new(
        'http://graph.biz/graphql',
        headers: { 'Authorization' => 'Bearer 1231' },
        allow_dynamic_queries: false
      ) do |client|
        client.http do |h|
          h.connection do |c|
            c.use Faraday::Adapter::Rack, Sinatra::Application
          end
        end
      end

      Query = Client.parse do
        query(some_ids: [:int]) do
          invoices(ids: :some_ids) do
            id
            fee_in_cents
          end
        end
      end
    end

    it 'defaults allow_dynamic_queries to false' do
      expect(Graphlient::Client::Spec::Client.send(:client).allow_dynamic_queries).to be false
    end

    it '#execute' do
      response = Graphlient::Client::Spec::Client.execute(Graphlient::Client::Spec::Query, some_ids: [42])
      invoices = response.data.invoices
      expect(invoices.first.id).to eq 42
      expect(invoices.first.fee_in_cents).to eq 20_000
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
graphlient-0.3.1 spec/graphlient/static_client_query_spec.rb
graphlient-0.3.0 spec/graphlient/static_client_query_spec.rb
graphlient-0.2.0 spec/graphlient/static_client_query_spec.rb