This repository was archived by the owner on Nov 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathin_spec.rb
48 lines (38 loc) · 1.38 KB
/
in_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
# frozen_string_literal: true
require 'spec_helper'
require 'json'
require 'tmpdir'
describe 'get' do
include CliIntegration
let(:proxy) { Billy::Proxy.new }
let(:dest_dir) { Dir.mktmpdir }
let(:git_dir) { Dir.mktmpdir }
let(:git_uri) { "file://#{git_dir}" }
before { proxy.start }
after { proxy.reset }
def git(cmd, dir = git_dir)
Dir.chdir(dir) { `git #{cmd}`.chomp }
end
def commit(msg)
git("-c user.name='test' -c user.email='[email protected]' commit -q --allow-empty -m '#{msg}'")
git('log --format=format:%H HEAD')
end
before do
git('init -q')
`rm -Rf #{git_dir}/.git/hooks`
@ref = commit('init')
commit('second')
git("update-ref refs/pull/1/head #{@ref}")
git("update-ref refs/pull/1/merge #{@ref}")
end
context 'for every PR that is checked out' do
before do
proxy.stub('https://api.github.com:443/repos/jtarchie/test/pulls/1')
.and_return(json: { html_url: 'http://example.com', number: 1, head: { ref: 'foo', repo: { full_name: 'repo/name' } }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' } })
end
it 'checks out the pull request to dest_dir' do
get(version: { ref: @ref, pr: '1' }, source: { access_token: 'abc', uri: git_uri, repo: 'jtarchie/test' })
expect(@ref).to eq git('log --format=format:%H HEAD', dest_dir)
end
end
end