Sha256: 948143ac13897200c394fccd2c00266213bffd6a376757f0083195d432b95ca0

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'
require './lib/wordpress/post'
require './lib/wordpress/blog'
require './lib/wordpress/post_attachment'

module Contentful
  module Exporter
    module Wordpress
      describe PostAttachment do
        before do
          xml_doc = Nokogiri::XML(File.open('spec/fixtures/wordpress.xml'))
          @items = xml_doc.search('item')
          @post = PostAttachment.new(@items[-2], @settings)
        end

        it 'can extract the url of an attachment' do
          url = @post.send(:attachment_url)

          expect(url).to eq 'https://szpryc.files.wordpress.com/2014/11/screen-shot-2014-11-27-at-12-34-47-pm.png'
        end

        it 'can extract the id of an attachment' do
          id = @post.send(:attachment_id)

          expect(id).to eq 'attachment_post_15'
        end

        it 'can extract the description of an attachment' do
          description = @post.send(:attachment_description)

          expect(description).to eq 'MOJ_DESC'
        end

        it 'is resilient against missing wp:meta_keys' do
          @post = PostAttachment.new(@items.last, @settings)
          description = @post.send(:attachment_description)

          expect(description).to eq ''
        end

        it 'is resilient against missing _wp_attachment_image_alt' do
          @post = PostAttachment.new(@items[2], @settings)
          description = @post.send(:attachment_description)

          expect(description).to eq ''
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wordpress-exporter-0.2.0 spec/lib/wordpress/post_attachment_spec.rb
wordpress-exporter-0.1.0 spec/lib/wordpress/post_attachment_spec.rb
wordpress-exporter-0.0.2 spec/lib/wordpress/post_attachment_spec.rb