Sha256: b941c41e02774c684b5bb207678159dfa4661fd37722cc893cebd0ce7b67a7c0

Contents?: true

Size: 940 Bytes

Versions: 1

Compression:

Stored size: 940 Bytes

Contents

require 'spec_helper'

describe 'PGit::Pivotal::IndividualRequest' do
  describe '#get!' do
    it 'does a cURL request' do
      class SomeSubclass < PGit::Pivotal::IndividualRequest
        attr_reader :api_token, :someattr
        def initialize
          @api_token
        end

        def sublink
          'some/link'
        end
      end

      json = double('JSON')
      some_subclass = SomeSubclass.new
      some_other_subclass = SomeSubclass.new

      api_token = some_subclass.api_token
      link = "https://www.pivotaltracker.com/services/v5/some/link"
      get_request = "curl -X GET -H 'X-TrackerToken: #{api_token}' #{link}"
      allow(JSON).to receive(:parse).with(json).and_return({ 'kind' => 'project', 'someattr' => '123'})
      allow(some_subclass).to receive(:`).with(get_request).and_return(json)

      some_subclass.get!

      expect(some_subclass).to have_received(:`).with(get_request)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pgit-1.0.0 spec/pgit/pivotal/individual_request_spec.rb