Created
November 3, 2009 22:29
-
-
Save kylefox/225513 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A StudentExam represents an Exam taken by a Student. | |
# It records the start/stop time, room number, etc. | |
class StudentExamTest < ActiveSupport::TestCase | |
should_belong_to :student | |
should_belong_to :exam | |
setup do | |
# These objects need to be created before we can create a StudentExam. Tests will NOT modify these objects. | |
# @school is a very time-expensive model to create (associations, external API calls, etc). | |
# We need a way to create the @school *ONCE* -- there's no need to recreate it for every single test. | |
@school = Factory(:school) | |
@student = Factory(:student, :school => @school) | |
@topic = Factory(:topic, :school => @school) | |
@exam = Factory(:exam, :topic => @topic) | |
end | |
context "A StudentExam" do | |
setup do | |
@student_exam = Factory(:student_exam, :exam => @exam, :student => @student, :room_number => "WB 302") | |
end | |
should "take place at 'Some School'" do | |
assert_equal @student_exam, 'Some School' | |
end | |
should "be in_progress? when created" do | |
assert @student_exam.in_progress? | |
end | |
should "not be in_progress? when finish! is called" do | |
@student_exam.finish! | |
assert !@student_exam.in_progress | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment