Sha256: b4a08c66446f2bbf2522ba1920eb2ae0d15eaec9fa3bb6e19f4a5f8a1370776b

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require File.join(File.dirname(__FILE__), '/../spec_helper')

describe BlogPostsHandler do
  include BlogPostsHandler

  before(:each) do
    post = Twog::Post.new(double('', pubDate: Time.now, link: 'http://tinyurl.com'))
    @posts = [post]
    @last_blog_post_tweeted = test_conf['last_blog_post_tweeted']
  end

  it 'should determine that there is one new blog post to tweet' do
    posts = get_new_blog_posts(@posts, @last_blog_post_tweeted)
    expect(posts.length).to eq(1)
  end

  it 'should return zero if posts are nil' do
    posts = get_new_blog_posts(nil, @last_blog_post_tweeted)
    expect(posts.length).to eq(0)
  end

  it 'should return zero if no posts are passed' do
    posts = get_new_blog_posts([], @last_blog_post_tweeted)
    expect(posts.length).to eq(0)
  end

  it 'should return the posts if there is no last_blog_post_tweeted in the conf file' do
    posts = get_new_blog_posts(@posts, nil)
    expect(posts.length).to eq(1)
  end

  it 'should return zero posts if the date is older than the last blog post date tweeted' do
    post = Twog::Post.new(double('', pubDate: (Date.parse(@last_blog_post_tweeted.to_s) - 10).to_s, link: 'http://tinyurl.com'))
    @posts = [post]
    posts = get_new_blog_posts(@posts, @last_blog_post_tweeted)
    expect(posts.length).to eq(0)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twog-0.3.6 spec/twog/blog_posts_handler_spec.rb