forked from github/github-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins_github_test.rb
34 lines (29 loc) · 914 Bytes
/
jenkins_github_test.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
require File.expand_path('../helper', __FILE__)
class JenkinsGitHubTest < Service::TestCase
def setup
@stubs = Faraday::Adapter::Test::Stubs.new
end
def test_push
@stubs.post "/github-webhook/" do |env|
assert_equal 'jenkins.example.com', env[:url].host
assert_equal 'Basic bW9ua2V5OnNlY3JldA==',
env[:request_headers]['authorization']
assert_equal 'application/x-www-form-urlencoded',
env[:request_headers]['content-type']
[200, {}, '']
end
svc = service :push,
{'jenkins_hook_url' => 'http://monkey:secret@jenkins.example.com/github-webhook/'}, payload
svc.receive_push
end
def test_no_jenkins_hook_url
assert_raises Service::ConfigurationError do
svc = service :push,
{'jenkins_hook_url' => ''}, payload
svc.receive_push
end
end
def service(*args)
super Service::JenkinsGitHub, *args
end
end