Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
getfitter / spec / get_fitter / request_spec.rb
Size: Mime:
describe GetFitter::Request do
  before do
    GetFitter::API.configure do |config|
      config.url = 'http://api.vagrant.dev:3000'
    end

    stub_get('/events/1/').to_return(status: [404, 'NOT FOUND'], body: fixture('404.json'), headers: { content_type: 'application/json; charset=utf-8' })
    stub_get('/events/85227a4e-a30f-4810-8738-ffd68c46d7f7/').to_return(body: fixture('event_85227a4e-a30f-4810-8738-ffd68c46d7f7.json'), headers: { content_type: 'application/json; charset=utf-8' })
  end

  let(:resource) { GetFitter::Event }
  let(:uri) { 'http://api.vagrant.dev:3000/events/1/' }
  let(:as) { GetFitter::Request::FORMAT }
  let(:method) { :get }

  let(:request) do
    GetFitter::Request.new(resource: resource.new, uri: uri, method: method, as: as)
  end

  describe '#perform_request' do
    let(:perform_request) { -> { request.send(:perform_request) } }
    it 'runs the request and verifies it' do
      allow(request).to receive(:perform_request)
      expect(request).to receive(:perform_request)
      perform_request.call
    end

    it 'raises an exception when data not found' do
      expect { request.perform_request }.to raise_error(GetFitter::Error::NotFound)
    end
  end
end