Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix specs

  • Loading branch information...
commit 1a9abf578256ff2a99cce81371cd986f1a0345a5 1 parent 9b55fb5
@gmarik gmarik authored
Showing with 30 additions and 22 deletions.
  1. +30 −22 spec/github_spec.rb
View
52 spec/github_spec.rb
@@ -17,7 +17,7 @@ def github
end
def base
- "https://loggyin%2Ftoken:tokkyen@github.com/api/v2/json"
+ 'https://api.github.com'
end
def should_raise e
@@ -26,14 +26,15 @@ def should_raise e
it "should get repo info" do
- stub = stub_request(:get, "#{base}/repos/show/vim-scripts/repo").
- to_return(:body => {}.to_json)
+ stub = stub_request(:get, "#{base}/repos/vim-scripts/repo").
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
+ to_return(:status => 200, :body => "", :headers => {})
github.info "repo"
stub.should have_been_requested
end
it "should get repo info for a nonexistent repo" do
- stub = stub_request(:get, "#{base}/repos/show/vim-scripts/repo").
+ stub = stub_request(:get, "#{base}/repos/vim-scripts/repo").
to_return(:status => 404, :body => { :error => "vim-scripts/repo Repository not found" }.to_json)
should_raise(Octokit::NotFound) {
github.info "repo"
@@ -45,18 +46,23 @@ def should_raise e
# For some reason these don't work:
# :body => { :data => { :values => {:has_issues => false, :has_wiki => false}}},
# :body => { :data => { "values[has_issues]" => false, "values[has_wiki]" => false}},
- stub = stub_request(:post, "#{base}/repos/show/vim-scripts/repo").
- with(:body => "values[has_issues]=false&values[has_wiki]=false").to_return(:body => {}.to_json)
+ stub = stub_request(:patch, "https://api.github.com/repos/vim-scripts/repo").
+ with(:body => "{\"has_issues\":false,\"has_wiki\":false}",
+ :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
+ to_return(:status => 200, :body => "", :headers => {})
github.turn_off_features "repo"
stub.should have_been_requested
end
it "should create a repository" do
- stub_a = stub_request(:post, "#{base}/repos/create").
- with(:body => "description=description&homepage=http%3A%2F%2Fhomepage&public=true&name=repo").
- to_return(:body => {:repository => {}}.to_json)
- stub_b = stub_request(:post, "#{base}/repos/show/vim-scripts/repo").
- with(:body => "values[has_issues]=false&values[has_wiki]=false").to_return(:body => {}.to_json)
+ stub_a = stub_request(:post, "https://api.github.com/user/repos").
+ with(:body => "{\"description\":\"description\",\"homepage\":\"http://homepage\",\"public\":true,\"name\":\"repo\"}",
+ :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
+ to_return(:status => 200, :body => "", :headers => {})
+ stub_b = stub_request(:patch, "https://api.github.com/repos/vim-scripts/repo").
+ with(:body => "{\"has_issues\":false,\"has_wiki\":false}",
+ :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
+ to_return(:status => 200, :body => "", :headers => {})
github.create "repo",
:description => "description",
@@ -68,24 +74,26 @@ def should_raise e
end
it "should delete a repository" do
- stub_a = stub_request(:post, "#{base}/repos/delete/repo").
- with(:headers => {'Content-Length'=>'0'}).to_return(:body => {}.to_json)
- stub_b = stub_request(:post, "#{base}/repos/delete/repo").
- with(:headers => {'Content-Type'=>'application/x-www-form-urlencoded'}).to_return(:body => { :status => :deleted }.to_json)
+ pending
+ stub_a = stub_request(:delete, "https://api.github.com/repos/repo/").
+ with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
+ to_return(:status => 200, :body => {:status => 'deleted' }.to_json, :headers => {})
github.delete "repo"
stub_a.should have_been_requested
- stub_b.should have_been_requested
end
it "should list all repos" do
- stub_a = stub_request(:get, "#{base}/repos/show/vim-scripts?page=1").
- to_return(:body => {:repositories => [{ :name => "one" }]}.to_json )
- stub_b = stub_request(:get, "#{base}/repos/show/vim-scripts?page=2").
- to_return(:body => {:repositories => [{ :name => "two" }]}.to_json )
- stub_c = stub_request(:get, "#{base}/repos/show/vim-scripts?page=3").
- to_return(:body => {:repositories => []}.to_json )
+ stub_a = stub_request(:get, "https://api.github.com/users/vim-scripts/repos?page=1").
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
+ to_return(:status => 200, :body => [{ :name => "one" }].to_json, :headers => {})
+ stub_b = stub_request(:get, "https://api.github.com/users/vim-scripts/repos?page=2").
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
+ to_return(:status => 200, :body => [{ :name => "two" }].to_json, :headers => {})
+ stub_c = stub_request(:get, "https://api.github.com/users/vim-scripts/repos?page=3").
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
+ to_return(:status => 200, :body => [].to_json, :headers => {})
result = github.list_all_repos
result.sort { |a,b| a['name'] <=> b['name'] }.should == [ { 'name' => 'one' }, { 'name' => 'two' } ]
Please sign in to comment.
Something went wrong with that request. Please try again.