February 2018
Intermediate to advanced
406 pages
9h 52m
English
Date and time logic has a well-deserved reputation as some of the most complex and irritating logic in any application. Testing calendar logic—including time-based reports, automatic logouts, and “1 day ago” text displays—can be a particular headache, but you can do a couple of things to simplify the time-logic beast.
You have a test that uses factories. You’d like to test some time-based code that might be used in a search or report result. This goes in spec/unit/project_spec.rb:
| | let(:runway) { create(:project, name: "Project Runway", |
| | start_date: "2018-01-20" } |
| | let(:greenlight) { create(:project, name: "Project Greenlight", |
| | start_date: "2018-02-24" } |
| | let(:gutenberg) { create( ... |