Skip to content

Instantly share code, notes, and snippets.

@partydrone
Created October 6, 2010 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save partydrone/612872 to your computer and use it in GitHub Desktop.
Save partydrone/612872 to your computer and use it in GitHub Desktop.
require 'test_helper'
class ProjectTest < ActiveSupport::TestCase
test "should be able to retrieve projects based on day" do
actual = projects(:huddle).reports_grouped_by_day
expected_keys = actual.keys.sort.map { |d| d.to_s(:db) }
assert_equal ["2009-01-06", "2009-01-07"], expected_keys
assert_equal [status_reports(:one_tue).id, status_reports(:two_tue).id], actual[Date.parse("2009-01-06")].map(&:id)
end
test "let's stub an object" do
stub_project = Project.new(:name => "Project Greenlight")
stub_project.stubs(:name)
assert_nil stub_project.name
end
test "let's stub an object again" do
stub_project = Project.new(:name => "Project Greenlight")
stub_project.stubs(:name).returns("Fred")
assert_equal "Fred", stub_project.name
end
test "let's stub a class" do
Project.stubs(:find).returns(Project.new(:name => "Project Greenlight"))
project = Project.find(1)
assert_equal "Project Greenlight", project.name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment