This repository has been archived by the owner on May 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 119
/
queue_spec.rb
67 lines (55 loc) · 2.33 KB
/
queue_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'spec_helper'
describe 'Job::Queue' do
def queue(*args)
Job::Queue.new(*args)
end
before do
Travis.config.queues = [
{ :queue => 'builds.rails', :slug => 'rails/rails' },
{ :queue => 'builds.clojure', :language => 'clojure' },
{ :queue => 'builds.erlang', :language => 'erlang' },
]
Job::Queue.instance_variable_set(:@queues, nil)
end
describe 'Queue.for' do
it 'returns the default build queue when neither slug or language match the given configuration hash' do
job = stub('job', :config => {}, :repository => stub('repository', :slug => 'travis-ci/travis-ci'))
Job::Queue.for(job).name.should == 'builds.common'
end
it 'returns the queue when slug matches the given configuration hash' do
job = stub('job', :config => {}, :repository => stub('repository', :slug => 'rails/rails'))
Job::Queue.for(job).name.should == 'builds.rails'
end
it 'returns the queue when language matches the given configuration hash' do
job = stub('job', :config => { :language => 'clojure' }, :repository => stub('repository', :slug => 'travis-ci/travis-ci'))
Job::Queue.for(job).name.should == 'builds.clojure'
end
it 'handles language being passed as an array gracefully' do
job = stub('job', :config => { :language => ['clojure'] }, :repository => stub('repository', :slug => 'travis-ci/travis-ci'))
Job::Queue.for(job).name.should == 'builds.clojure'
end
end
describe 'Queue.queues' do
it 'returns an array of Queues for the config hash' do
rails, clojure, erlang = Job::Queue.send(:queues)
rails.name.should == 'builds.rails'
rails.slug.should == 'rails/rails'
clojure.name.should == 'builds.clojure'
clojure.language.should == 'clojure'
end
end
describe 'matches?' do
it "returns false when neither of slug or language match" do
queue = queue('builds.common', nil, nil)
queue.send(:matches?, 'foo/bar', 'COBOL').should be_false
end
it "returns true when the given slug matches" do
queue = queue('builds.rails', 'rails/rails')
queue.send(:matches?, 'rails/rails', nil).should be_true
end
it "returns true when the given language matches" do
queue = queue('builds.common', nil, 'clojure')
queue.send(:matches?, nil, 'clojure').should be_true
end
end
end