Initial commit
This commit is contained in:
47
spec/helpers/duration_helper_spec.rb
Normal file
47
spec/helpers/duration_helper_spec.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe DurationHelper do
|
||||
describe '#convert_duration' do
|
||||
it 'returns the same value if the from and to are the same unit' do
|
||||
result = helper.convert_duration(60, from: :seconds, to: :seconds)
|
||||
|
||||
expect(result).to eq(60)
|
||||
end
|
||||
|
||||
it 'converts seconds into minutes' do
|
||||
result = helper.convert_duration(60, from: :seconds, to: :minutes)
|
||||
|
||||
expect(result).to eq(1)
|
||||
end
|
||||
|
||||
it 'converts seconds into hours' do
|
||||
result = helper.convert_duration(3600, from: :seconds, to: :hours)
|
||||
|
||||
expect(result).to eq(1)
|
||||
end
|
||||
|
||||
it 'converts minutes into seconds' do
|
||||
result = helper.convert_duration(1, from: :minutes, to: :seconds)
|
||||
|
||||
expect(result).to eq(60)
|
||||
end
|
||||
|
||||
it 'converts minutes into hours' do
|
||||
result = helper.convert_duration(60, from: :minutes, to: :hours)
|
||||
|
||||
expect(result).to eq(1)
|
||||
end
|
||||
|
||||
it 'converts hours into seconds' do
|
||||
result = helper.convert_duration(1, from: :hours, to: :seconds)
|
||||
|
||||
expect(result).to eq(3600)
|
||||
end
|
||||
|
||||
it 'converts hours into minutes' do
|
||||
result = helper.convert_duration(1, from: :hours, to: :minutes)
|
||||
|
||||
expect(result).to eq(60)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user