forked from octokit/octokit.rb
/
helper.rb
65 lines (52 loc) · 1.11 KB
/
helper.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
require 'simplecov'
SimpleCov.start
require 'octokit'
require 'rspec'
require 'webmock/rspec'
def a_delete(url)
a_request(:delete, github_url(url))
end
def a_get(url)
a_request(:get, github_url(url))
end
def a_patch(url)
a_request(:patch, github_url(url))
end
def a_post(url)
a_request(:post, github_url(url))
end
def a_put(url)
a_request(:put, github_url(url))
end
def stub_delete(url)
stub_request(:delete, github_url(url))
end
def stub_get(url)
stub_request(:get, github_url(url))
end
def stub_patch(url)
stub_request(:patch, github_url(url))
end
def stub_post(url)
stub_request(:post, github_url(url))
end
def stub_put(url)
stub_request(:put, github_url(url))
end
def fixture_path
File.expand_path("../fixtures", __FILE__)
end
def fixture(file)
File.new(fixture_path + '/' + file)
end
def github_url(url)
if url =~ /^http/
url
elsif @client && @client.authenticated?
"https://pengwynn%2Ftoken:OU812@api.github.com#{url}"
elsif @client && @client.oauthed?
"https://api.github.com#{url}?access_token=#{@client.oauth_token}"
else
"https://api.github.com#{url}"
end
end