forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_spec.rb
More file actions
121 lines (95 loc) · 3.38 KB
/
Copy pathlist_spec.rb
File metadata and controls
121 lines (95 loc) · 3.38 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# encoding: utf-8
require 'spec_helper'
describe Github::GitData::References, '#list' do
let(:user) { 'peter-murach' }
let(:repo) { 'github' }
let(:ref) { "heads/master" }
let(:request_path) { "/repos/#{user}/#{repo}/git/refs/#{ref}".gsub(/(\/)+/, '/') }
before {
stub_get(request_path).to_return(:body => body, :status => status,
:headers => {:content_type => "application/json; charset=utf-8"})
}
after { reset_authentication_for(subject) }
context "get all the refernces based on sub-namespace" do
let(:body) { fixture('git_data/references.json') }
let(:status) { 200 }
it { should respond_to :all }
it "should fail to get resource without username" do
expect { subject.list nil, repo }.to raise_error(ArgumentError)
end
context 'with invalid reference' do
let(:ref) { '/branch/featureA' }
it "should fail to call" do
expect {
subject.list user, repo, :ref => ref
}.to_not raise_error(ArgumentError, /reference/)
end
end
context 'with valid reference' do
let(:ref) { 'heads/lleger-refactor' }
it "should pass with valid reference" do
expect {
subject.list user, repo, :ref => ref
}.to_not raise_error(ArgumentError, /reference/)
end
end
context 'with valid reference and refs branch name' do
let(:ref) { 'refactors/lleger-refactor' }
it "should pass with valid reference" do
expect {
subject.list user, repo, :ref => ref
}.to_not raise_error(ArgumentError, /reference/)
end
end
context 'with valid renference and refs' do
let(:ref) { 'refs/heads/lleger-refactor' }
it "should pass with valid reference" do
expect {
subject.list user, repo, :ref => ref
}.to_not raise_error(ArgumentError, /reference/)
end
end
context 'with valid renference and refs with leading slash' do
let(:ref) { '/refs/heads/lleger-refactor' }
it "should pass with valid reference" do
expect {
subject.list user, repo, :ref => ref
}.to_not raise_error(ArgumentError, /reference/)
end
end
it "should get the resources" do
subject.list user, repo, :ref => ref
a_get(request_path).should have_been_made
end
it "should return array of resources" do
references = subject.list user, repo, :ref => ref
references.should be_an Enumerable
references.should have(3).items
end
it "should be a mash type" do
references = subject.list user, repo, :ref => ref
references.first.should be_a Hashie::Mash
end
it "should get reference information" do
references = subject.list user, repo, :ref => ref
references.first.ref.should eql 'refs/heads/master'
end
it "should yield to a block" do
yielded = []
result = subject.list(user, repo, :ref => ref) { |obj| yielded << obj }
yielded.should == result
end
end
context "get all the references on the system" do
let(:request_path) { "/repos/#{user}/#{repo}/git/refs" }
let(:body) { fixture('git_data/references.json') }
let(:status) { 200 }
it "should get the resources" do
subject.list user, repo
a_get(request_path).should have_been_made
end
end
it_should_behave_like 'request failure' do
let(:requestable) { subject.list user, repo, :ref => ref }
end
end # list