45 lines
1.6 KiB
Ruby
45 lines
1.6 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Travis::API::V3::ServiceIndex do
|
|
let(:headers) {{ }}
|
|
let(:path) { '/' }
|
|
let(:json) { JSON.load(response.body) }
|
|
let(:response) { get(path, {}, headers) }
|
|
|
|
describe "custom json entry point" do
|
|
let(:expected_resources) {{
|
|
"repository" => {
|
|
"find" => [{"request-method"=>"GET", "uri-template"=>"#{path}repo/{id}"}]
|
|
}
|
|
}}
|
|
|
|
describe 'with /v3 prefix' do
|
|
let(:path) { '/v3/' }
|
|
specify(:resources) { expect(json['resources']).to be == expected_resources }
|
|
end
|
|
|
|
describe 'with Accept header' do
|
|
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.3+json' } }
|
|
specify(:resources) { expect(json['resources']).to be == expected_resources }
|
|
end
|
|
|
|
describe 'with Travis-API-Version header' do
|
|
let(:headers) { { 'HTTP_TRAVIS_API_VERSION' => '3' } }
|
|
specify(:resources) { expect(json['resources']).to be == expected_resources }
|
|
end
|
|
end
|
|
|
|
describe "json-home document" do
|
|
describe 'with /v3 prefix' do
|
|
let(:headers) { { 'HTTP_ACCEPT' => 'application/json-home' } }
|
|
let(:path) { '/v3/' }
|
|
specify(:resources) { expect(json['resources']).to include("http://schema.travis-ci.com/rel/repository/find") }
|
|
end
|
|
|
|
describe 'with Travis-API-Version header' do
|
|
let(:headers) { { 'HTTP_ACCEPT' => 'application/json-home', 'HTTP_TRAVIS_API_VERSION' => '3' } }
|
|
specify(:resources) { expect(json['resources']).to include("http://schema.travis-ci.com/rel/repository/find") }
|
|
end
|
|
end
|
|
end
|