forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_spec.rb
More file actions
102 lines (80 loc) · 3.17 KB
/
search_spec.rb
File metadata and controls
102 lines (80 loc) · 3.17 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
# encoding: utf-8
require 'spec_helper'
describe Github::Search do
let(:keyword) { 'api' }
after { reset_authentication_for(subject) }
context "#issues" do
let(:owner) { 'peter-murach' }
let(:repo) { 'github' }
let(:state) { 'closed' }
before do
stub_get("/legacy/issues/search/#{owner}/#{repo}/#{state}/#{keyword}").
to_return(:body => fixture('search/issues.json'), :status => 200,
:headers => {:content_type => "application/json; charset=utf-8"})
end
it "should get the resources" do
subject.issues owner, repo, state, keyword
a_get("/legacy/issues/search/#{owner}/#{repo}/#{state}/#{keyword}").should have_been_made
end
it "should get the resources through params hash" do
subject.issues :owner => owner, :repo => repo, :state => state, :keyword => keyword
a_get("/legacy/issues/search/#{owner}/#{repo}/#{state}/#{keyword}").should have_been_made
end
it "should get issue information" do
issues = subject.issues :owner => owner, :repo => repo, :state => state, :keyword => keyword
issues.issues.first.user.should == 'ckarbass'
end
end
context "#repositories" do
before do
stub_get("/legacy/repos/search/#{keyword}").
to_return(:body => fixture('search/repositories.json'), :status => 200,
:headers => {:content_type => "application/json; charset=utf-8"})
end
it { expect { subject.repos }.to raise_error(ArgumentError) }
it "should get the resources" do
subject.repos keyword
a_get("/legacy/repos/search/#{keyword}").should have_been_made
end
it "should get the resource through params hash" do
subject.repos :keyword => keyword
a_get("/legacy/repos/search/#{keyword}").should have_been_made
end
it "should get repository information" do
repos = subject.repos :keyword => keyword
repos.repositories.first.username.should == 'mathiasbynens'
end
end
context "#users" do
before do
stub_get("/legacy/user/search/#{keyword}").
to_return(:body => fixture('search/users.json'), :status => 200,
:headers => {:content_type => "application/json; charset=utf-8"})
end
it { expect { subject.users }.to raise_error(ArgumentError) }
it "should get the resources" do
subject.users :keyword => keyword
a_get("/legacy/user/search/#{keyword}").should have_been_made
end
it "should get user information" do
users = subject.users :keyword => keyword
users.users.first.username.should == 'techno'
end
end
context "#email" do
before do
stub_get("/legacy/user/email/#{keyword}").
to_return(:body => fixture('search/email.json'), :status => 200,
:headers => {:content_type => "application/json; charset=utf-8"})
end
it { expect { subject.email }.to raise_error(Github::Error::RequiredParams) }
it "should get the resources" do
subject.email :email => keyword
a_get("/legacy/user/email/#{keyword}").should have_been_made
end
it "should get user information" do
user = subject.email :email => keyword
user.user.username.should == 'techno'
end
end
end # Github::Search