-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest.rb
executable file
·67 lines (63 loc) · 1.99 KB
/
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
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
#!/usr/bin/ruby
# Test our Sinatra Tracker Post-receive hook
#
require 'net/http'
require 'rubygems'
payload = <<-eos
payload={
"before": "5aef35982fb2d34e9d9d4502f6ede1072793222d",
"repository": {
"url": "http://github.com/chris/tracker_github_hook",
"name": "github",
"description": "You're lookin' at it.",
"watchers": 5,
"forks": 2,
"private": 1,
"owner": {
"email": "[email protected]",
"name": "chris"
}
},
"commits": [
{
"id": "41a212ee83ca127e3c8cf465891ab7216a705f59",
"url": "http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
"author": {
"email": "[email protected]",
"name": "Chris Bailey"
},
"message": "This one is a comment only 10 [Story294825] and [Story1234] 2nd line commit",
"timestamp": "2008-02-15T14:57:17-08:00",
"added": ["filepath.rb"]
},
{
"id": "41a212ee83ca321e3c8cf465891cb7216a705f59",
"url": "http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
"author": {
"email": "[email protected]",
"name": "Chris Bailey"
},
"message": "This one does not have a story association",
"timestamp": "2008-02-15T14:58:17-08:00",
"added": ["filepath.rb"]
},
{
"id": "de8251ff97ee194a289832576287d6f8ad74e3d0",
"url": "http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0",
"author": {
"email": "[email protected]",
"name": "Chris Bailey"
},
"message": "comment and state change 10 [Story294825 state:finished]",
"timestamp": "2008-02-15T14:36:34-08:00"
}
],
"after": "de8251ff97ee194a289832576287d6f8ad74e3d0",
"ref": "refs/heads/master"
}
eos
headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
http = Net::HTTP.new('localhost', 4567)
resp, data = http.post('/', payload, headers)
puts "Response code: #{resp.code}"
puts "Response body: #{data}"