spec/model/slideshow_spec.rb in slideshare_api-0.0.2 vs spec/model/slideshow_spec.rb in slideshare_api-0.0.3

- old
+ new

@@ -5,14 +5,36 @@ let(:slideshow_xml) { Nokogiri::XML(open('spec/fixtures/slideshow.xml').read) } subject { SlideshareApi::Model::Slideshow.new slideshow_xml } it { expect(subject.original_slideshow_xml).to eq slideshow_xml } - it { expect(subject.id).to eq slideshow_xml.search('ID').text } + it { expect(subject.id).to eq slideshow_xml.search('ID').text.to_i } it { expect(subject.title).to eq slideshow_xml.search('Title').text } it { expect(subject.description).to eq slideshow_xml.search('Description').text } - it { expect(subject.status).to eq slideshow_xml.search('Status').text } + + describe 'status' do + context 'queued_for_conversion' do + before { slideshow_xml.search('Status').first.content = 0 } + it { expect(subject.status).to eq :queued_for_conversion } + end + + context 'converting' do + before { slideshow_xml.search('Status').first.content = 1 } + it { expect(subject.status).to eq :converting } + end + + context 'converted' do + before { slideshow_xml.search('Status').first.content = 2 } + it { expect(subject.status).to eq :converted } + end + + context 'conversion_failed' do + before { slideshow_xml.search('Status').first.content = 3 } + it { expect(subject.status).to eq :conversion_failed } + end + end + it { expect(subject.username).to eq slideshow_xml.search('Username').text } it { expect(subject.url).to eq slideshow_xml.search('URL').text } it { expect(subject.thumbnail_url).to eq slideshow_xml.search('ThumbnailURL').text } it { expect(subject.thumbnail_size).to eq slideshow_xml.search('ThumbnailSize').text } it { expect(subject.thumbnail_small_url).to eq slideshow_xml.search('ThumbnailSmallURL').text } @@ -30,41 +52,70 @@ context 'it is not downloadable' do before { slideshow_xml.search('Download').first.content = 0 } it { expect(subject.is_downloadable).to eq false } end - it { expect(subject.slideshow_type).to eq slideshow_xml.search('SlideshowType').text } + describe 'type' do + context 'presentation' do + before { slideshow_xml.search('SlideshowType').first.content = 0 } + it { expect(subject.type).to eq :presentation } + end + context 'document' do + before { slideshow_xml.search('SlideshowType').first.content = 1 } + it { expect(subject.type).to eq :document } + end + + context 'portfolio' do + before { slideshow_xml.search('SlideshowType').first.content = 2 } + it { expect(subject.type).to eq :portfolio } + end + + context 'video' do + before { slideshow_xml.search('SlideshowType').first.content = 3 } + it { expect(subject.type).to eq :video } + end + end + context 'it is in contest' do before { slideshow_xml.search('InContest').first.content = 1 } it { expect(subject.is_in_contest).to eq true } end context 'it is not in contest' do before { slideshow_xml.search('InContest').first.content = 0 } it { expect(subject.is_in_contest).to eq false } end - it { expect(subject.user_id).to eq slideshow_xml.search('UserID').text } + it { expect(subject.user_id).to eq slideshow_xml.search('UserID').text.to_i } it { expect(subject.ppt_location).to eq slideshow_xml.search('PPTLocation').text } it { expect(subject.stripped_title).to eq slideshow_xml.search('StrippedTitle').text } it { expect(subject.tags).to eq slideshow_xml.search('Tag').map(&:text) } - it { expect(subject.download_count).to eq slideshow_xml.search('NumDownloads').text } - it { expect(subject.view_count).to eq slideshow_xml.search('NumViews').text } - it { expect(subject.comment_count).to eq slideshow_xml.search('NumComments').text } - it { expect(subject.favorite_count).to eq slideshow_xml.search('NumFavorites').text } - it { expect(subject.slide_count).to eq slideshow_xml.search('NumSlides').text } - it { expect(subject.related_slideshow_ids).to eq slideshow_xml.search('RelatedSlideshowID').map(&:text) } - it { expect(subject.privacy_level).to eq slideshow_xml.search('PrivacyLevel').text } + it { expect(subject.download_count).to eq slideshow_xml.search('NumDownloads').text.to_i } + it { expect(subject.view_count).to eq slideshow_xml.search('NumViews').text.to_i } + it { expect(subject.comment_count).to eq slideshow_xml.search('NumComments').text.to_i } + it { expect(subject.favorite_count).to eq slideshow_xml.search('NumFavorites').text.to_i } + it { expect(subject.slide_count).to eq slideshow_xml.search('NumSlides').text.to_i } + it { expect(subject.related_slideshow_ids).to eq slideshow_xml.search('RelatedSlideshowID').map(&:text).map(&:to_i) } + context 'it is private' do + before { slideshow_xml.search('PrivacyLevel').first.content = 1 } + it { expect(subject.is_private).to eq true } + end + + context 'it is not private' do + before { slideshow_xml.search('PrivacyLevel').first.content = 0 } + it { expect(subject.is_private).to eq false } + end + context 'it is flagged' do before { slideshow_xml.search('FlagVisible').first.content = 1 } - it { expect(subject.is_flagged).to eq true } + it { expect(subject.is_not_flagged).to eq true } end context 'it is not flagged' do before { slideshow_xml.search('FlagVisible').first.content = 0 } - it { expect(subject.is_flagged).to eq false } + it { expect(subject.is_not_flagged).to eq false } end context 'it is visible' do before { slideshow_xml.search('ShowOnSS').first.content = 1 } it { expect(subject.is_visible).to eq true } \ No newline at end of file