fix: linear spec

This commit is contained in:
Shivam Mishra
2024-05-03 13:36:24 +05:30
parent c5e34669f6
commit 7e61397186
+4 -2
View File
@@ -2,10 +2,12 @@ require 'rails_helper'
describe Linear do
let(:api_key) { 'valid_api_key' }
let(:url) { 'https://api.linear.app/graphql' }
let(:linear_client) { described_class.new(api_key) }
let(:headers) { { 'Content-Type' => 'application/json', 'Authorization' => api_key } }
let(:client) { Graphlient::Client.new('https://swapi-graphql.netlify.app/.netlify/functions/index', schema_path: 'spec/fixtures/linear-schema.json', headers: headers) }
let(:schema) { JSON.parse(File.read('spec/fixtures/linear-schema.json')) }
let(:client) { Graphlient::Client.new(url, schema: Graphlient::Schema.new({ 'data' => schema }, nil), headers: headers) }
it 'raises an exception if the API key is absent' do
expect { described_class.new(nil) }.to raise_error(ArgumentError, 'Missing Credentials')
@@ -28,7 +30,7 @@ describe Linear do
context 'when the API response is success' do
before do
linear_client.instance_variable_set(:@client, client)
stub_request(:post, 'https://swapi-graphql.netlify.app/.netlify/functions/index')
stub_request(:post, url)
.to_return(status: 200, body: { data: { teams: { nodes: [{ id: 'team1', name: 'Team One' }] } } }.to_json)
end