Skip to content

Commit

Permalink
Set up a shared description for the Base class
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrick Wiebe committed Feb 26, 2009
1 parent cfca0df commit 205696b
Showing 1 changed file with 66 additions and 76 deletions.
142 changes: 66 additions & 76 deletions spec/ruby_picasa/types_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,97 +3,70 @@

include RubyPicasa

describe Base do
describe 'for Album' do
before :all do
@xml = open_file('album.atom').read
end
describe 'a RubyPicasa document', :shared => true do
it 'should have an id' do
@object.id.should_not be_nil
end

before do
@parent = mock('parent')
@album = Album.new(@xml, @parent)
@album.session = mock('session')
end
it 'should have an author' do
@object.author.should_not be_nil
@object.author.name.should == 'Liz'
@object.author.uri.should == 'http://picasaweb.google.com/liz'
end

it 'should have an id' do
@album.id.should_not be_nil
end
it 'should get links by name' do
@object.link('abc').should be_nil
@object.link('alternate').href.should_not be_nil
end

it 'should have an author' do
@album.author.should_not be_nil
@album.author.name.should == 'Liz'
@album.author.uri.should == 'http://picasaweb.google.com/liz'
end
it 'should do nothing for previous and next' do
@object.previous.should be_nil
@object.next.should be_nil
end

it 'should get links by name' do
@album.link('abc').should be_nil
@album.link('alternate').href.should == 'http://picasaweb.google.com/liz/Lolcats'
end
it 'should load' do
@object.session.expects(:get_url).with(@object.id, {})
@object.load
end

it 'should do nothing for previous and next' do
@album.previous.should be_nil
@album.next.should be_nil
it 'should have links' do
@object.links.should_not be_empty
@object.links.each do |l|
l.should be_an_instance_of(Objectify::Atom::Link)
end
end

it 'should load' do
@album.session.expects(:get_url).with(@album.id, {})
@album.load
describe 'session' do
it 'should return @session' do
@object.session = :sess
@object.session.should == :sess
end

it 'should have 6 links' do
@album.links.length.should == 6
@album.links.each do |l|
l.should be_an_instance_of(Objectify::Atom::Link)
end
it 'should get the parent session' do
@object.session = nil
@parent.expects(:session).returns(:parent_sess)
@object.session.should == :parent_sess
end

describe 'session' do
it 'should return @session' do
@album.session = :sess
@album.session.should == :sess
end

it 'should get the parent session' do
@album.session = nil
@parent.expects(:session).returns(:parent_sess)
@album.session.should == :parent_sess
end

it 'should be nil if no parent' do
@album.session = nil
@album.expects(:parent).returns nil
@album.session.should be_nil
end
end

describe 'first Photo' do
before do
@photo = @album.entries.first
@photo.should be_an_instance_of(Photo)
end

it 'should have a content' do
@photo.content.should be_an_instance_of(PhotoUrl)
end

it 'should have 3 thumbnails' do
@photo.thumbnails.length.should == 3
@photo.thumbnails.each do |t|
t.should be_an_instance_of(PhotoUrl)
end
end
it 'should be nil if no parent' do
@object.session = nil
@object.expects(:parent).returns nil
@object.session.should be_nil
end
end
end


describe User do
it_should_behave_like 'a RubyPicasa document'

before :all do
@xml = open_file('user.atom').read
@class = User
end

before do
@parent = mock('parent')
@user = User.new(@xml, @parent)
@object = @user = User.new(@xml, @parent)
@user.session = mock('session')
end

Expand All @@ -107,20 +80,27 @@
end

describe Album do
it_should_behave_like 'a RubyPicasa document'

before :all do
@xml = open_file('album.atom').read
end

before do
@parent = mock('parent')
@album = Album.new(@xml, @parent)
@object = @album = Album.new(@xml, @parent)
@album.session = mock('session')
end

it 'should have 1 entry' do
@album.entries.length.should == 1
end

it 'should get links by name' do
@album.link('abc').should be_nil
@album.link('alternate').href.should == 'http://picasaweb.google.com/liz/Lolcats'
end

describe 'photos' do
it 'should use entries if available' do
@album.expects(:session).never
Expand Down Expand Up @@ -156,13 +136,23 @@
it 'should not have an author' do
@photo.author.should be_nil
end
end

end
it 'should have a content' do
@photo.content.should be_an_instance_of(PhotoUrl)
end

describe 'for Search' do
it 'should request next'
it 'should request previous'
it 'should have 3 thumbnails' do
@photo.thumbnails.length.should == 3
@photo.thumbnails.each do |t|
t.should be_an_instance_of(PhotoUrl)
end
end
end

end

describe Search do
it 'should request next'
it 'should request previous'
end

0 comments on commit 205696b

Please sign in to comment.