spec/model/user_spec.rb in yammer-client-0.1.2 vs spec/model/user_spec.rb in yammer-client-0.1.3
- old
+ new
@@ -6,10 +6,14 @@
Yammer.configure do |conf|
conf.access_token = 'TolNOFka9Uls2DxahNi78A'
end
end
+ after :all do
+ Yammer.reset!
+ end
+
context 'class methods' do
subject { Yammer::User }
describe '#create' do
@@ -28,10 +32,27 @@
:headers => { 'Location' => 'https://www.yammer.com/api/v1/users/364'}
)
subject.create('hacker@yammer-inc.com')
end
end
+
+ describe '#current_user' do
+ it "should fetch authenticated user's data" do
+ stub_request(:get, "https://www.yammer.com/api/v1/users/current").with(
+ :headers => {
+ 'Accept' => 'application/json',
+ 'Authorization' => "Bearer #{Yammer.access_token}",
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
+ }
+ ).to_return(
+ :status => 200,
+ :body => fixture('user.json'),
+ :headers => {}
+ )
+ subject.current
+ end
+ end
end
context 'new user object with id' do
before :each do
@@ -105,9 +126,41 @@
:status => 200,
:body => fixture('user.json'),
:headers => {}
)
expect(subject.email).to eq 'jsmith@yammer-inc.com'
+ end
+ end
+
+ describe "#followers" do
+ it 'returns users following user' do
+ stub_request(:get, "https://www.yammer.com/api/v1/users/following/2").
+ with(:headers => {
+ 'Accept'=>'application/json',
+ 'Authorization'=>"Bearer #{Yammer.access_token}",
+ 'User-Agent'=>"Yammer Ruby Gem #{Yammer::Version}"
+ }).to_return(
+ :status => 200,
+ :body => fixture('users_following.json'),
+ :headers => {}
+ )
+ subject.followers
+ end
+ end
+
+ describe "#following" do
+ it 'returns users followed by user' do
+ stub_request(:get, "https://www.yammer.com/api/v1/users/followed_by/2").
+ with(:headers => {
+ 'Accept'=>'application/json',
+ 'Authorization'=>"Bearer #{Yammer.access_token}",
+ 'User-Agent'=>"Yammer Ruby Gem #{Yammer::Version}"
+ }).to_return(
+ :status => 200,
+ :body => fixture('users_followed.json'),
+ :headers => {}
+ )
+ subject.following
end
end
describe "#delete" do
it 'deletes user' do
\ No newline at end of file