Permalink
Browse files

some tests for initializing with incorrect args

  • Loading branch information...
1 parent 5374ec9 commit da4a3caf0ca44a434acc02b3f269567131a2afd2 @justinfrench committed Dec 31, 2008
Showing with 34 additions and 0 deletions.
  1. +34 −0 test/active_time_test.rb
View
@@ -9,5 +9,39 @@ class ActiveTimeTest < ActiveSupport::TestCase
teardown do
teardown_db
end
+
+ context "ActiveRecord::Base subclasses" do
+
+ should "respond to the in_date_range named scope" do
+ assert Post.respond_to?(:in_date_range)
+ end
+
+ end
+
+ context "ActiveTime" do
+
+ context "when incorrectly initialized" do
+
+ should "raise ArgumentError when no args are provided" do
+ assert_raise ArgumentError do
+ ActiveTime.new()
+ end
+ end
+
+ should "raise ArgumentError when one Time arg is provided" do
+ assert_raise ArgumentError do
+ ActiveTime.new(Time.now)
+ end
+ end
+
+ should "not raise ArgumentError when two Time args are provided" do
+ assert_nothing_raised ArgumentError do
+ ActiveTime.new(Time.now, 1.minute.from_now)
+ end
+ end
+
+ end
+
+ end
end

0 comments on commit da4a3ca

Please sign in to comment.