Sha256: 80f523092f4f039b7f7a3c8e077da7f163ad857e89cf79dfe4667f6ec0c67911

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

ENV['RACK_ENV'] = 'test'

require 'test_helper'
require 'rack/test'
require 'service_contract/avro/documentation'

class DocumentationJsonTest < Minitest::Test
  include Rack::Test::Methods

  def app
    SampleDocumentation
  end

  def setup
    super
    header "Accept", "application/json"
  end

  def test_homepage_json
    get '/'
    assert_equal "application/json", last_response.headers["Content-Type"]
    assert_equal({"contract" => {
      "name" => "SampleService",
      "title" => "Avro Service",
      "description" => "",
      "release_version" => "0.1.2",
      "versions" => [
        {"version" => "1", "link" => "/1"},
        {"version" => "2", "link" => "/2"},
      ]
    }}, JSON.parse(last_response.body))
  end

  def test_version_index_json
    get '/1'
    assert_equal "application/json", last_response.headers["Content-Type"]
    assert_equal({"version" => {
      "version" => "1",
      "protocols" => [
        {"name" => "city_state", "link" => "/1/city_state"},
        {"name" => "location", "link" => "/1/location"},
        {"name" => "sales_region", "link" => "/1/sales_region"},
      ]
    }}, JSON.parse(last_response.body))
  end

  def test_protocol_json
    get '/1/city_state'
    assert_equal "application/json", last_response.headers["Content-Type"]
    assert_equal File.read(File.expand_path("../sample/1/compiled/city_state.avpr", __FILE__)),
      last_response.body
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
service_contract-0.6.0 test/documentation_json_test.rb