Created
September 25, 2011 23:08
-
-
Save batasrki/1241298 to your computer and use it in GitHub Desktop.
Example model display work window spec
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
describe Job do | |
before :each do | |
@mock_job_category = JobCategory.create!({:name => "Tester"}) | |
@mock_client = mock_model(Client, {:name => "Test Client"}) | |
@job = Job.new(:name => "test job", :client => @mock_client, | |
:category => @mock_job_category) | |
end | |
describe "work window date range" do | |
before :each do | |
@now = DateTime.now.in_time_zone | |
@formatted_now = @now.strftime("%b %d, %Y") | |
end | |
it "should display a generic message if there's no start or end time" do | |
@job.display_work_window.should == "No date range specified" | |
end | |
it "should display a work commencment message if there's a start date, but no end date" do | |
@job.starttime = @now | |
@job.display_work_window.should == "Work commences on #{@formatted_now}" | |
end | |
it "should display a work completed message if there's a end date, but no start date" do | |
@job.endtime = @now | |
@job.display_work_window.should == "Work completed by #{@formatted_now}" | |
end | |
it "should display a date range if both start and end date exist" do | |
@job.starttime = @now | |
@job.endtime = @now + 1.week | |
formatted_end = (@now + 1.week).strftime("%b %d, %Y") | |
@job.display_work_window.should == "#{@formatted_now} ~ #{formatted_end}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment