Sha256: 230e8625124d55e43f76fb340a380a94c048a2b7a0fc0abe88545feb56dd8607

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

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

describe BlogPostsHandler do 
  include BlogPostsHandler

  before(:each) do
    post = Twog::Post.new(stub('', :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)
    posts.length.should == 1
  end

  it "should return zero if posts are nil" do
    posts = get_new_blog_posts(nil, @last_blog_post_tweeted)
    posts.length.should == 0
  end
  
  it "should return zero if no posts are passed" do
    posts = get_new_blog_posts([], @last_blog_post_tweeted)
    posts.length.should == 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)
    posts.length.should == 1
  end

  it "should return zero posts if the date is older than the last blog post date tweeted" do
    post = Twog::Post.new(stub('', :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)
    posts.length.should == 0
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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