Sha256: 4bbec18c5475843a98219cd29560f98bf1f6db4153e338e18b48a21f104bf6fd

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe 'History' 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
    @history = Feed2Mail::History.new @config
  end

  after do
    @hist_file.close
    @hist_file.unlink
  end

  it 'load history file' do
    @history.has?('http://example.net/sample-uri-1').should be_true
    @history.has?('http://example.net/sample-uri-2').should be_true
    @history.has?('http://example.net/sample-uri-3').should be_false
  end

  it 'save history file' do
    @history << 'http://example.net/sample-uri-new'
    @history.save!

    @new_history = Feed2Mail::History.new @config
    @new_history.has?('http://example.net/sample-uri-1').should be_true
    @new_history.has?('http://example.net/sample-uri-2').should be_true
    @new_history.has?('http://example.net/sample-uri-new').should be_true
  end

  context 'no history file' do
    before do
      config = Feed2Mail::Config.new
      hist_file = File.expand_path(File.dirname(__FILE__) + '/data/NONE.yaml')
      config.hist_file = hist_file
      @history = Feed2Mail::History.new config
    end

    it 'has empty history when no history file' do
      @history.instance_variable_get('@hist').should be_empty
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feed2mail-0.0.1 spec/history_spec.rb