# -*- encoding: UTF-8 -*- require File.dirname(__FILE__) + '/spec_helper.rb' describe Timelog4r, ' when first created' do before do @accessor = Timelog4r.new @dummy_image = ' http://a.com http://a.com http://a.com ' @dummy_author_a = ' a a 1' + @dummy_image + '' @dummy_author_b = ' b b 2' + @dummy_image + '' @dummy_tag = 'hoge,fuga,' @dummy_entry_a = ' a a 0' + @dummy_tag + ' a a a 200201220122' + @dummy_author_a + '' @dummy_entry_b = ' b b 1' + @dummy_tag + '200202011010 200201220122 b b' + @dummy_author_b + '' @dummy_entry_c = ' c c 2' + @dummy_tag + ' a a a 200201220122' + @dummy_author_a + '' @dummy_timeline = ' hoge 200202020101' + @dummy_author_a + @dummy_entry_a + @dummy_entry_b + @dummy_entry_c + '' @dummy_user_list = ' a 200210202020 10' + @dummy_author_a + ' a a 200503050607' + @dummy_image + ' ' @dummy_tag_list = ' a 200405060708 hoge 10 ' @dummy_profile = ' a 200510111213 a a http://a.com http://a.com a hoge,fuga,' + @dummy_image + ' ' end it 'should be have a user agent "timelog4r"' do @accessor.user_agent.should be_eql('timelog4r') end it 'should not have a user id' do @accessor.user_id.should be_nil end it 'should not have a password' do @accessor.password.should be_nil end describe ' when get public timeline' do before do doc = REXML::Document.new(@dummy_timeline) @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(doc) end it 'successful should be a kind of Hash' do @accessor.get_public_timeline.should be_a_kind_of(Hash) end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when get my timeline' do before do doc = REXML::Document.new(@dummy_timeline) @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(doc) end it 'success should be a kind of Hash' do @accessor.get_my_timeline.should be_a_kind_of(Hash) end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when get reply list' do before do doc = REXML::Document.new(@dummy_timeline) @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(doc) end it 'success should be a kind of Hash' do @accessor.get_reply_list.should be_a_kind_of(Hash) end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when get direct messages' do before do doc = REXML::Document.new(@dummy_timeline) @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(doc) end it 'success should be a kind of Hash' do @accessor.get_direct_messages.should be_a_kind_of(Hash) end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when get friends timeline' do before do doc = REXML::Document.new(@dummy_timeline) @accessor.should_receive(:http_access).once.and_return(doc) end it 'successful should be a kind of Hash' do @accessor.get_friends_timeline.should be_a_kind_of(Hash) end end describe ' when get tag list' do before do doc = REXML::Document.new(@dummy_tag_list) @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(doc) end it 'success should be a kind of Hash' do @accessor.get_tag_list.should be_a_kind_of(Hash) end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when get profile' do before do doc = REXML::Document.new(@dummy_profile) @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(doc) end it 'success should be a kind of Hash' do @accessor.get_profile.should be_a_kind_of(Hash) end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when get friend list' do before do doc = REXML::Document.new(@dummy_user_list) @accessor.user_id = 'dummy' @accessor.user_id = 'dummy' @accessor.should_receive(:http_access).once.and_return(doc) end it 'success should be a kind of Hash' do @accessor.get_friend_list.should be_a_kind_of(Hash) end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when get fan list' do before do doc = REXML::Document.new(@dummy_user_list) @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(doc) end it 'success should be a kind of Hash' do @accessor.get_fan_list.should be_a_kind_of(Hash) end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when update' do before do @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(true) end it 'success should be true' do @accessor.update('hoge').should be_true end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when send direct message' do before do @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(true) end it 'success should be true' do @accessor.send_message('hoge', 'fuga').should be_true end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when set todo' do before do @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(true) end it 'success should be true' do @accessor.set_todo('hoge', Time.new).should be_true end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when update bookmark' do before do @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(true) end it 'success should be true' do @accessor.update_bookmark('hoge', URI.parse('http://a.com')).should be_true end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when update good' do before do @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(true) end it 'success should be true' do @accessor.update_good('hoge', 'fuga', ['moge']).should be_true end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when update news' do before do @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(true) end it 'success should be true' do @accessor.update_news('hoge').should be_true end after do @accessor.user_id = nil @accessor.password = nil end end describe ' when update vote' do before do @accessor.user_id = 'dummy' @accessor.password = 'dummy' @accessor.should_receive(:http_access).once.and_return(true) end it 'success should be true' do @accessor.update_vote('hoge').should be_true end after do @accessor.user_id = nil @accessor.password = nil end end after do @accessor = nil end end