Sha256: 1cbc4b755529c960af947ba340f65310185b781a29ef3e5d60624a012d907513

Contents?: true

Size: 1.02 KB

Versions: 19

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true
require 'sinatra/base'

# the FakeApi class is used to mock API requests while testing.
class FakeApi < Sinatra::Base
  # timeout
  get('/v2/resources/timeout') { status 419 }

  # resource
  post('/v2/resources') { json_response 201, 'resource.json' }
  get('/v2/resources/:id') { json_response 200, 'resource.json' }
  get('/v2/resources') { json_response 200, 'resources.json' }
  put('/v2/resources') { json_response 201, 'resource.json' }
  delete('/v2/resources/:id') { status 202 }

  # version
  get('/v2/version') { 'Version => 2.1.29-.20161208.172810' }

  # errors
  get('/v2/client_error') { json_response 400, 'error.json' }
  get('/v2/server_error') { status 500 }
  get('/v2/proxy_error') { status 407 }

  # relevance
  get('/v2/relevance/ruleset/names') { json_response 200, 'relevance_ruleset_names.json' }

  private

  def json_response(response_code, file_name)
    content_type :json
    status response_code
    File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finapps_core-2.0.20 spec/support/fake_api.rb
finapps_core-2.0.19 spec/support/fake_api.rb
finapps_core-2.0.18 spec/support/fake_api.rb
finapps_core-2.0.17 spec/support/fake_api.rb
finapps_core-2.0.16 spec/support/fake_api.rb
finapps_core-2.0.15 spec/support/fake_api.rb
finapps_core-2.0.14 spec/support/fake_api.rb
finapps_core-2.0.13 spec/support/fake_api.rb
finapps_core-2.0.12 spec/support/fake_api.rb
finapps_core-2.0.11 spec/support/fake_api.rb
finapps_core-2.0.10 spec/support/fake_api.rb
finapps_core-2.0.9 spec/support/fake_api.rb
finapps_core-2.0.8 spec/support/fake_api.rb
finapps_core-2.0.7 spec/support/fake_api.rb
finapps_core-2.0.6 spec/support/fake_api.rb
finapps_core-2.0.5 spec/support/fake_api.rb
finapps_core-2.0.4 spec/support/fake_api.rb
finapps_core-2.0.3 spec/support/fake_api.rb
finapps_core-2.0.2 spec/support/fake_api.rb