spec/github/users/followers_spec.rb in github_api-0.4.11 vs spec/github/users/followers_spec.rb in github_api-0.5.0.rc1

- old
+ new

@@ -6,43 +6,45 @@ let(:github) { Github.new } let(:user) { 'peter-murach' } after { reset_authentication_for github } - describe "#followers" do + describe "#list" do + it { github.users.followers.should respond_to :all } + context "resource found for a user" do before do stub_get("/users/#{user}/followers"). to_return(:body => fixture('users/followers.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"}) end it "should get the resources" do - github.users.followers user + github.users.followers.list user a_get("/users/#{user}/followers").should have_been_made end it "should return resource" do - followers = github.users.followers user + followers = github.users.followers.list user followers.should be_an Array followers.should have(1).items end it "should be a mash type" do - followers = github.users.followers user + followers = github.users.followers.list user followers.first.should be_a Hashie::Mash end it "should get followers information" do - followers = github.users.followers user + followers = github.users.followers.list user followers.first.login.should == 'octocat' end it "should yield to a block" do - github.users.should_receive(:followers).with(user).and_yield('web') - github.users.followers(user) { |param| 'web' } + github.users.followers.should_receive(:list).with(user).and_yield('web') + github.users.followers.list(user) { |param| 'web' } end end context "resource found for an authenticated user" do before do @@ -53,11 +55,11 @@ :status => 200, :headers => {:content_type => "application/json; charset=utf-8"}) end it "should get the resources" do - github.users.followers + github.users.followers.list a_get("/user/followers"). with(:query => { :access_token => "#{OAUTH_TOKEN}"}). should have_been_made end end @@ -68,15 +70,15 @@ to_return(:body => "", :status => [404, "Not Found"]) end it "should return 404 with a message 'Not Found'" do expect { - github.users.followers user + github.users.followers.list user }.to raise_error(Github::Error::NotFound) end end - end # followers + end # list describe "#following" do context "resource found for a user" do before do stub_get("/users/#{user}/following"). @@ -84,33 +86,33 @@ :status => 200, :headers => {:content_type => "application/json; charset=utf-8"}) end it "should get the resources" do - github.users.following user + github.users.followers.following user a_get("/users/#{user}/following").should have_been_made end it "should return resource" do - followings = github.users.following user + followings = github.users.followers.following user followings.should be_an Array followings.should have(1).items end it "should be a mash type" do - followings = github.users.following user + followings = github.users.followers.following user followings.first.should be_a Hashie::Mash end it "should get following users information" do - followings = github.users.following user + followings = github.users.followers.following user followings.first.login.should == 'octocat' end it "should yield to a block" do - github.users.should_receive(:following).with(user).and_yield('web') - github.users.following(user) { |param| 'web' } + github.users.followers.should_receive(:following).with(user).and_yield('web') + github.users.followers.following(user) { |param| 'web' } end end context "resource found for an authenticated user" do before do @@ -121,11 +123,11 @@ :status => 200, :headers => {:content_type => "application/json; charset=utf-8"}) end it "should get the resources" do - github.users.following + github.users.followers.following a_get("/user/following"). with(:query => { :access_token => "#{OAUTH_TOKEN}"}). should have_been_made end end @@ -136,11 +138,11 @@ to_return(:body => "", :status => [404, "Not Found"]) end it "should return 404 with a message 'Not Found'" do expect { - github.users.following user + github.users.followers.following user }.to raise_error(Github::Error::NotFound) end end end # following @@ -154,32 +156,32 @@ :headers => {:content_type => "application/json; charset=utf-8"}) end it 'should raise error if username not present' do expect { - github.users.following? nil + github.users.followers.following? nil }.to raise_error(ArgumentError) end it 'should perform request' do - github.users.following?(user) + github.users.followers.following?(user) a_get("/user/following/#{user}"). with(:query => { :access_token => "#{OAUTH_TOKEN}"}). should have_been_made end it 'should return true if user is being followed' do - github.users.following?(user).should be_true + github.users.followers.following?(user).should be_true end it 'should return false if user is not being followed' do stub_get("/user/following/#{user}"). with(:query => { :access_token => "#{OAUTH_TOKEN}"}). to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"}) - github.users.following?(user).should be_false + github.users.followers.following?(user).should be_false end end # following? context '#follow' do before do @@ -191,23 +193,23 @@ :headers => {:content_type => "application/json; charset=utf-8"}) end it "should raise error if gist id not present" do expect { - github.users.follow nil + github.users.followers.follow nil }.to raise_error(ArgumentError) end it 'successfully unfollows a user' do - github.users.follow(user) + github.users.followers.follow(user) a_put("/user/following/#{user}"). with(:query => { :access_token => "#{OAUTH_TOKEN}"}). should have_been_made end it "should return 204 with a message 'Not Found'" do - github.users.follow(user).status.should be 204 + github.users.followers.follow(user).status.should be 204 end end # follow context '#unfollow' do before do @@ -219,22 +221,22 @@ :headers => {:content_type => "application/json; charset=utf-8"}) end it "should raise error if gist id not present" do expect { - github.users.unfollow nil + github.users.followers.unfollow nil }.to raise_error(ArgumentError) end it 'successfully unfollows a user' do - github.users.unfollow(user) + github.users.followers.unfollow(user) a_delete("/user/following/#{user}"). with(:query => { :access_token => "#{OAUTH_TOKEN}"}). should have_been_made end it "should return 204 with a message 'Not Found'" do - github.users.unfollow(user).status.should be 204 + github.users.followers.unfollow(user).status.should be 204 end end # unfollow end # Github::Users::Followers