spec/github/orgs_spec.rb in github_api-0.4.11 vs spec/github/orgs_spec.rb in github_api-0.5.0.rc1
- old
+ new
@@ -6,58 +6,65 @@
let(:github) { Github.new }
let(:user) { 'peter-murach' }
let(:repo) { 'github' }
let(:org) { 'github' }
- after { github.user, github.repo, github.oauth_token = nil, nil, nil }
+ after { reset_authentication_for github }
- describe "orgs" do
+ context 'access to apis' do
+ it { subject.members.should be_a Github::Orgs::Members }
+ it { subject.teams.should be_a Github::Orgs::Teams }
+ end
+
+ describe "#list" do
context "resource found for a user" do
before do
stub_get("/users/#{user}/orgs").
- to_return(:body => fixture('orgs/orgs.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
+ to_return(:body => fixture('orgs/orgs.json'), :status => 200,
+ :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should get the resources" do
- github.orgs.orgs user
+ github.orgs.list user
a_get("/users/#{user}/orgs").should have_been_made
end
it "should return array of resources" do
- orgs = github.orgs.orgs user
+ orgs = github.orgs.list user
orgs.should be_an Array
orgs.should have(1).items
end
it "should be a mash type" do
- orgs = github.orgs.orgs user
+ orgs = github.orgs.list user
orgs.first.should be_a Hashie::Mash
end
it "should get org information" do
- orgs = github.orgs.orgs user
+ orgs = github.orgs.list user
orgs.first.login.should == 'github'
end
it "should yield to a block" do
- github.orgs.should_receive(:orgs).with(user).and_yield('web')
- github.orgs.orgs(user) { |param| 'web' }
+ github.orgs.should_receive(:list).with(user).and_yield('web')
+ github.orgs.list(user) { |param| 'web' }
end
end
context "resource found for an au user" do
before do
github.oauth_token = OAUTH_TOKEN
stub_get("/user/orgs").
with(:query => { :access_token => OAUTH_TOKEN }).
- to_return(:body => fixture('orgs/orgs.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
+ to_return(:body => fixture('orgs/orgs.json'), :status => 200,
+ :headers => {:content_type => "application/json; charset=utf-8"})
end
- after { github.oauth_token = nil }
+ # after { github.oauth_token = nil }
it "should get the resources" do
- github.orgs.orgs
+ github.orgs.list
a_get("/user/orgs").with(:query => { :access_token => OAUTH_TOKEN }).
should have_been_made
end
end
@@ -67,59 +74,60 @@
to_return(:body => "", :status => [404, "Not Found"])
end
it "should return 404 with a message 'Not Found'" do
expect {
- github.orgs.orgs user
+ github.orgs.list user
}.to raise_error(Github::Error::NotFound)
end
end
- end # orgs
+ end # list
- describe "org" do
+ describe "#get" do
context "resource found" do
before do
stub_get("/orgs/#{org}").
to_return(:body => fixture('orgs/org.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should fail to get resource without org name" do
- expect { github.orgs.org }.to raise_error(ArgumentError)
+ expect { github.orgs.get }.to raise_error(ArgumentError)
end
it "should get the resource" do
- github.orgs.org org
+ github.orgs.get org
a_get("/orgs/#{org}").should have_been_made
end
it "should get org information" do
- organisation = github.orgs.org org
+ organisation = github.orgs.get org
organisation.id.should == 1
organisation.login.should == 'github'
end
it "should return mash" do
- organisation = github.orgs.org org
+ organisation = github.orgs.get org
organisation.should be_a Hashie::Mash
end
end
context "resource not found" do
before do
stub_get("/orgs/#{org}").
- to_return(:body => fixture('orgs/org.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
+ to_return(:body => fixture('orgs/org.json'), :status => 404,
+ :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should fail to retrive resource" do
expect {
- github.orgs.org org
+ github.orgs.get org
}.to raise_error(Github::Error::NotFound)
end
end
- end # org
+ end # get
- describe "edit_org" do
+ describe "#edit" do
let(:inputs) do
{ :billing_email => 'support@github.com',
:blog => "https://github.com/blog",
:company => "GitHub",
:email => "support@github.com",
@@ -128,43 +136,45 @@
end
context "resource edited successfully" do
before do
stub_patch("/orgs/#{org}").with(inputs).
- to_return(:body => fixture("orgs/org.json"), :status => 200, :headers => { :content_type => "application/json; charset=utf-8"})
+ to_return(:body => fixture("orgs/org.json"), :status => 200,
+ :headers => { :content_type => "application/json; charset=utf-8"})
end
it "should fail to edit without 'user/repo' parameters" do
- expect { github.orgs.edit_org }.to raise_error(ArgumentError)
+ expect { github.orgs.edit }.to raise_error(ArgumentError)
end
it "should edit the resource" do
- github.orgs.edit_org org
+ github.orgs.edit org
a_patch("/orgs/#{org}").with(inputs).should have_been_made
end
it "should return resource" do
- organisation = github.orgs.edit_org org
+ organisation = github.orgs.edit org
organisation.should be_a Hashie::Mash
end
it "should be able to retrieve information" do
- organisation = github.orgs.edit_org org
+ organisation = github.orgs.edit org
organisation.name.should == 'github'
end
end
context "failed to edit resource" do
before do
stub_patch("/orgs/#{org}").with(inputs).
- to_return(:body => fixture("orgs/org.json"), :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
+ to_return(:body => fixture("orgs/org.json"), :status => 404,
+ :headers => { :content_type => "application/json; charset=utf-8"})
end
it "should fail to find resource" do
expect {
- github.orgs.edit_org org
+ github.orgs.edit org
}.to raise_error(Github::Error::NotFound)
end
end
- end # edit_org
+ end # edit
end # Github::Orgs