fix tests for cc.xml

This commit is contained in:
Sven Fuchs 2012-11-08 14:47:50 +01:00
parent f7fdfaa96a
commit ab841a0a23
3 changed files with 20 additions and 3 deletions

View File

@ -42,7 +42,7 @@ GIT
GIT
remote: git://github.com/travis-ci/travis-core.git
revision: 23c0c1b07f34033e598f02bfd03ec99b01198fce
revision: 27275b7f26023cf8e1379cca9a9760f46dc9a45c
specs:
travis-core (0.0.1)
actionmailer (~> 3.2.3)

View File

@ -31,14 +31,19 @@ describe 'Repos' do
response.should deliver_json_for(Repository.by_slug('svenfuchs/minimal').first, version: 'v2')
end
it 'GET /repos/1/cc.xml' do
response = get "repos/#{repo.id}/cc.xml"
response.should deliver_cc_xml_for(Repository.by_slug('svenfuchs/minimal').first)
end
it 'GET /repos/svenfuchs/minimal' do
response = get '/repos/svenfuchs/minimal', {}, headers
response.should deliver_json_for(Repository.by_slug('svenfuchs/minimal').first, version: 'v2')
end
it 'GET /repos/svenfuchs/minimal/cc.xml' do
response = get '/repos/svenfuchs/minimal/cc.xml', {}, headers
response.should deliver_xml_for(Repository.by_slug('svenfuchs/minimal').first, version: 'v2')
response = get '/repos/svenfuchs/minimal/cc.xml'
response.should deliver_cc_xml_for(Repository.by_slug('svenfuchs/minimal').first)
end
describe 'GET /repos/svenfuchs/minimal.png?branch=foo,bar' do

View File

@ -45,6 +45,18 @@ RSpec::Matchers.define :deliver_result_image_for do |name|
end
end
RSpec::Matchers.define :deliver_cc_xml_for do |repo|
match do |response|
body = response.body
failure_message_for_should do
"expected #{body} to be a valid cc.xml"
end
body.include?('<Projects>') && body.include?(%(name="#{repo.slug}"))
end
end
RSpec::Matchers.define :redirect_to do |expected|
match do |response|
actual = response.headers['location'].to_s.sub('http://example.org', '')