Sha256: 20c4719dadcd358f73aa016dd915326256da4aac02ee819a99071e2dd3c23fe3

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

module RestfullAccessibleStub
  def stub_get_request(url, resource_name)
    stub_request(:get, url)
      .with(
        headers: request_headers
      ).to_return(
        status: 200,
        body: %Q[{#{resource_name}: "dummy"}]
      )
  end

  def stub_get_request_not_found(url)
    stub_request(:get, url)
      .with(
        headers: request_headers
      ).to_return(
        status: 404,
        body: "itemNotFound"
      )
  end

  def stub_get_request_unauthorized(url)
    stub_request(:get, url)
      .with(
        headers: request_headers
      ).to_return(
        status: 401,
        body: "unauthorized"
      )
  end

  def request_headers
    {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>"Faraday v#{Faraday::VERSION}"}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yao-0.9.0 test/support/restfully_accesible_stub.rb