add test for new helpers
This commit is contained in:
parent
d9925f00e9
commit
8320f78d0b
2 changed files with 37 additions and 71 deletions
37
spec/helpers/date_time_helper_spec.rb
Normal file
37
spec/helpers/date_time_helper_spec.rb
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DateTimeHelper, type: :helper do
|
||||
|
||||
describe 'format_datetime' do
|
||||
it 'returns nothing if there is no parameter' do
|
||||
expect(format_datetime(nil)).to eq nil
|
||||
end
|
||||
|
||||
it 'returns formatted string' do
|
||||
datetime = Time.zone.local(2016, 05, 04, 11, 30)
|
||||
expect(format_datetime(datetime)).to eq '2016-05-04 11:30'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'show_time' do
|
||||
it 'when length > 60' do
|
||||
expect(show_time(67)).to eq '1 h 7 min'
|
||||
end
|
||||
|
||||
it 'when length = 60' do
|
||||
expect(show_time(60)).to eq '1 h'
|
||||
end
|
||||
|
||||
it 'when length < 60' do
|
||||
expect(show_time(58)).to eq '58 min'
|
||||
end
|
||||
|
||||
it 'when length > 60 and is a decimal number' do
|
||||
expect(show_time(68.3)).to eq '1 h 8 min'
|
||||
end
|
||||
|
||||
it 'when length is nil' do
|
||||
expect(show_time(nil)).to eq '0 h 0 min'
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue