Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
add more spec coverage, now at 86%
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeridth committed Apr 19, 2010
1 parent 55e5745 commit 3478b26
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
28 changes: 24 additions & 4 deletions spec/twog/post_spec.rb
Expand Up @@ -5,18 +5,26 @@
before(:each) do
updated = stub('update', :content => '2010-04-02T01:00:00-06:00')
link = stub('link', :href => 'http://tinyurl.com')
@post = stub('post', :updated => updated, :link => link)
title = stub('title', :content => 'test title')
@post = stub('post', :updated => updated, :link => link, :title => title)

end

it "should return a link" do

twog_post = Twog::Post.new(@post)

twog_post.link.should == "http://tinyurl.com"
twog_post.date.should == "2010-04-02T01:00:00-06:00"
end

it "should return a date" do
twog_post = Twog::Post.new(@post)
twog_post.date.should == "2010-04-02T01:00:00-06:00"
end

it "should return a title" do
twog_post = Twog::Post.new(@post)
twog_post.title.should == "test title"
end

it "should sort multiple posts" do
unsorted = (1..10).sort_by { rand }.collect do |i|
updated = stub('update', :content => (Time.now + (60*60*24*i)).to_s)
Expand All @@ -29,6 +37,18 @@

sorted.inject {|i, j| Time.parse(i.date.to_s).should be < Time.parse(j.date.to_s); j }
end

it "should leave meeting list alone if all the times are the same" do
unsorted = (1..10).collect do |i|
updated = stub('update', :content => (Time.now + (60*60*24*3)).to_s)
link = stub('link', :href => 'http://tinyurl.com')
post = stub('post', :updated => updated, :link => link)
Twog::Post.new(post)
end
sorted = unsorted.sort!
sorted.length.should == 10
sorted.should == unsorted
end
end

context "when rss entry has pubDate and link" do
Expand Down
14 changes: 14 additions & 0 deletions spec/twog/twog_spec.rb
Expand Up @@ -35,4 +35,18 @@
Bitly.stub!(:new).and_return("hello")
get_bitly_from(test_conf).should == "hello"
end

it "should get the version" do
YAML.stub!(:load).and_return({:major => "1", :minor => "0", :patch => "0"})
version.should == "1.0.0"
end

it "should get the posts to tweet" do
conf = test_conf
self.should_receive(:parse_feed).with(conf['rss_feed']).and_return(1)
self.should_receive(:map).with(1).and_return(2)
self.should_receive(:get_new_blog_posts).with(2, conf['last_blog_post_tweeted'])

get_posts_to_tweet(conf)
end
end

0 comments on commit 3478b26

Please sign in to comment.