require 'helper' describe Bearcat::Client::GraphQL do let(:url) { '/api/graphql' } before do @client = Bearcat::Client.new(prefix: 'http://canvas.instructure.com', token: 'test_token') end it 'returns scores for an assignment group' do query = { query: "{ assignmentGroup(id: \"29\") { id name gradesConnection { nodes { finalGrade finalScore enrollment{ _id } } } } }" } stub_post(@client, url).with(body: query).to_return(json_response('graph_ql_scores.json')) res = @client.graphql_query(query) res['data']['assignmentGroup']['gradesConnection']['nodes'].count.should eq 3 res['data']['assignmentGroup']['name'].should eq 'Assignments' res['data']['assignmentGroup']['gradesConnection']['nodes'][0]['currentScore'].should eq 100 end end