Sha256: abd30f6a8ce69d1febd9b06bca94831786eaa3b8b2eaebc575b5a1ff0cac7642

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Feedzirra::FeedUtilities do
  before(:each) do
    @klass = Class.new do
      include Feedzirra::FeedEntryUtilities
    end
  end
  
  describe "handling dates" do
    it "should parse an ISO 8601 formatted datetime into Time" do
      time = @klass.new.parse_datetime("2008-02-20T8:05:00-010:00")
      time.class.should == Time
      time.to_s.should == "Wed Feb 20 18:05:00 UTC 2008"
    end
  end
  
  describe "sanitizing" do
    before(:each) do
      @feed = Feedzirra::Feed.parse(sample_atom_feed)
      @entry = @feed.entries.first
    end
    
    it "should provide a sanitized title" do
      new_title = "<script>" + @entry.title
      @entry.title = new_title
      @entry.sanitized.title.should == Dryopteris.sanitize(new_title)
    end
    
    it "should sanitize things in place" do
      @entry.title   += "<script>"
      @entry.author  += "<script>"
      @entry.content += "<script>"

      cleaned_title   = Dryopteris.sanitize(@entry.title)
      cleaned_author  = Dryopteris.sanitize(@entry.author)
      cleaned_content = Dryopteris.sanitize(@entry.content)
      
      @entry.sanitize!
      @entry.title.should   == cleaned_title
      @entry.author.should  == cleaned_author
      @entry.content.should == cleaned_content
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
pauldix-feedzirra-0.0.2 spec/feedzirra/feed_entry_utilities_spec.rb
somezack-feedzirra-0.0.2 spec/feedzirra/feed_entry_utilities_spec.rb