Sha256: 8c77935acda7174a312f68b25ff41cfc3d1086716168929e3d49678d2cdc3a70
Contents?: true
Size: 815 Bytes
Versions: 5
Compression:
Stored size: 815 Bytes
Contents
require 'habitica_cli/api' RSpec.describe HabiticaCli::Api do def response_headers { 'content-type' => 'application/json' } end it 'attaches user name and token to request' do stub_request(:get, /.*habitica.com.*/) api = HabiticaCli::Api.new('test_user', 'test_key') api.get('test') expect(WebMock).to have_requested(:get, 'https://habitica.com/api/v3/test') .with(headers: { :'X-Api-Key' => 'test_key', :'X-Api-User' => 'test_user' }) # rubocop:disable Metrics/LineLength end it 'returns json' do stub_request(:get, /.*habitica.com.*/).to_return( body: JSON.dump(key: 'value'), headers: response_headers ) api = HabiticaCli::Api.new('test_user', 'test_key') response = api.get('test') expect(response.body['key']).to eql('value') end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
habitica_cli-1.0.2 | spec/api_spec.rb |
habitica_cli-1.0.1 | spec/api_spec.rb |
habitica_cli-1.0.0 | spec/api_spec.rb |
habitica_cli-0.1.1 | spec/api_spec.rb |
habitica_cli-0.1.0 | spec/api_spec.rb |