-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More human time periods on event show title
- Loading branch information
1 parent
8c826e5
commit a503c49
Showing
4 changed files
with
65 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe ApplicationHelper, type: :helper do | ||
context 'fancy_time_period_format' do | ||
it 'gives correct text for a given input' do | ||
times = [ | ||
{ hour: 0, minute: 0, text: "zero minutes" }, | ||
{ hour: 23, minute: 59, text: 'all day' }, | ||
{ hour: 0, minute: 15, text: '15 minutes' }, | ||
{ hour: 0, minute: 30, text: 'half an hour' }, | ||
{ hour: 1, minute: 0, text: 'an hour' }, | ||
{ hour: 2, minute: 0, text: '2 hours' }, | ||
{ hour: 3, minute: 30, text: '3 and a half hours' }, | ||
{ hour: 4, minute: 45, text: '4 hours and 45 minutes' } | ||
] | ||
|
||
times.each do |check| | ||
starts_at = Time.new(2000, 1, 1, 0, 0, 0) | ||
ends_at = Time.new(2000, 1, 1, check[:hour], check[:minute], 0) | ||
|
||
out = fancy_time_period_format(starts_at, ends_at) | ||
expect(out).to eq check[:text] | ||
end | ||
end | ||
end | ||
end |