Sha256: c24227336b23755ca0982f14e694b8aeba0c7b4f587846f626ee700c9569e26c

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe 'Report' do
  before do
    @config = Feed2Mail::Config.new
    @hist_file = Tempfile.new 'hist'
    FileUtils.cp File.expand_path(File.dirname(__FILE__) + '/data/history.yaml'),
      @hist_file.path
    @config.hist_file = @hist_file.path
  end

  after do
    @hist_file.close
    @hist_file.unlink
  end

  context '#new' do
    it 'return empty output with no items' do
      report = Feed2Mail::Report.new @config
      report.to_s.should == ''
    end
  end

  context 'reporting' do
    before do
      feed_uri = File.expand_path(File.dirname(__FILE__) + '/data/feed.rss')
      @config.feeds << Feed2Mail::Feed.new(feed_uri)
      @report = Feed2Mail::Report.new @config
      @report.update
    end

    it 'contains feed items' do
      @report.to_s.should match('Item 1 title')
      @report.to_s.should match('Item 2 title « & »')
    end

    it 'contains feed items links' do
      @report.to_s.should match('http://feed-sample.example.net/item/1')
      @report.to_s.should match('http://feed-sample.example.net/item/2')
    end

    it 'mails the content' do
      Pony.stub!(:deliver)
      Pony.should_receive(:deliver) do |mail|
        mail.to_s.should match /^From: from@example.net\r$/
        mail.to_s.should match /^To: to@example.net\r$/
        mail.to_s.should match /^Subject: Feed2Mail: new feed items published\r$/
        mail.to_s.should match /^http:\/\/feed-sample\.example\.net\/item\/1\r$/
        #FIXME use 8bit instead of quoted-printable?
        #mail.to_s.should match /^Item 2 title « & »\r$/
      end
      @report.mail :from => 'from@example.net', :to => 'to@example.net'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feed2mail-0.0.1 spec/report_spec.rb