Skip to content
This repository has been archived by the owner on Oct 6, 2018. It is now read-only.

Commit

Permalink
Cleaned up deprecation and other noise when tests are being run.
Browse files Browse the repository at this point in the history
  • Loading branch information
technicalpickles committed Jul 31, 2009
1 parent b36c6c4 commit 9f92569
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 9 deletions.
11 changes: 5 additions & 6 deletions app/models/entry.rb
@@ -1,10 +1,9 @@
class Entry < ActiveRecord::Base
include Pacecar
include Feedra::Entry

def self.recent(limit)
limited(limit).by_published_at(:desc).by_created_at(:desc)
end

named_scope :recent, lambda { |limit|
{
:limit => limit,
:order => 'published_at desc, created_at desc'
}
}
end
2 changes: 2 additions & 0 deletions test/unit/company_test.rb
Expand Up @@ -6,6 +6,8 @@ class CompanyTest < ActiveSupport::TestCase
@company = Factory(:company, :name => "Nike")
end

subject { @company }

should_validate_presence_of :name
should_validate_uniqueness_of :name
should_validate_url_format_of :website_url
Expand Down
27 changes: 26 additions & 1 deletion test/unit/entry_test.rb
Expand Up @@ -5,5 +5,30 @@ class EntryTest < ActiveSupport::TestCase
assert Entry.included_modules.include?(Feedra::Entry)
end

should_have_named_scope 'recent(5)', :order => 'published_at desc, created_at desc', :limit => 5
context "recent" do

setup do
@expected = stub('entries')

Entry.stub_chain(:limited, :by_published_at, :by_created_at).returns(@expected)
@actual = Entry.recent(5)
end

should "return the entries" do
assert_equal @expected, @actual
end

should "get 5 entries" do
assert_received(Entry, :limited) {|subject| subject.with(5) }
end

should "sort by published_at, descending" do
assert_received(Entry, :by_published_at) {|subject| subject.with(:desc) }
end

should "sort by created_at, descending" do
assert_received(Entry, :by_created_at) {|subject| subject.with(:desc) }
end

end
end
2 changes: 2 additions & 0 deletions test/unit/event_test.rb
Expand Up @@ -7,6 +7,8 @@ class EventTest < ActiveSupport::TestCase
@event = Factory(:event, :title => "Hackfest")
end

subject { @event }

should_validate_presence_of :date, :title, :location
should_have_markup :description, :required => true, :cache_html => true

Expand Down
2 changes: 2 additions & 0 deletions test/unit/presentation_test.rb
Expand Up @@ -6,6 +6,8 @@ class PresentationTest < ActiveSupport::TestCase
@presentation = Factory(:presentation, :title => "Agile Design")
end

subject { @presentation }

should_belong_to :user

should "display name as string representation" do
Expand Down
2 changes: 2 additions & 0 deletions test/unit/project_test.rb
Expand Up @@ -6,6 +6,8 @@ class ProjectTest < ActiveSupport::TestCase
@project = Factory(:project, :name => "Paperclip")
end

subject { @project }

should_validate_presence_of :name, :user_id
should_validate_url_format_of :github_url

Expand Down
3 changes: 2 additions & 1 deletion test/unit/tweet_test.rb
Expand Up @@ -4,8 +4,9 @@ class TweetTest < ActiveSupport::TestCase
should "be valid with factory" do
assert_valid Factory.build(:tweet)
end

should_belong_to :user
should_have_index :user_id
should_have_db_index :user_id
should_validate_presence_of :text, :twitter_id, :tweeted_at, :user_id

context "recent five Tweets given six existing Tweets" do
Expand Down
3 changes: 2 additions & 1 deletion test/unit/user_test.rb
Expand Up @@ -3,7 +3,6 @@
class UserTest < ActiveSupport::TestCase
should "respond to gravatar_url" do
user = Factory(:user, :email => 'john@doe.com')
puts user.gravatar_url
assert_respond_to user, :gravatar_url
end

Expand All @@ -12,6 +11,8 @@ class UserTest < ActiveSupport::TestCase
@user = Factory(:user, :twitter => "Croaky")
end

subject { @user }

should_have_many :tweets
should_have_many :projects
should_have_one :feed, :dependent => :destroy
Expand Down

0 comments on commit 9f92569

Please sign in to comment.