strftime_spec.rb 782 B

1234567891011121314151617181920212223242526
  1. require 'spec_helper'
  2. describe 'strftime' do
  3. it 'exists' do
  4. expect(Puppet::Parser::Functions.function('strftime')).to eq('function_strftime')
  5. end
  6. it 'raises a ParseError if there is less than 1 arguments' do
  7. expect { scope.function_strftime([]) }.to(raise_error(Puppet::ParseError))
  8. end
  9. it 'using %s should be higher then when I wrote this test' do
  10. result = scope.function_strftime(['%s'])
  11. expect(result.to_i).to(be > 1_311_953_157)
  12. end
  13. it 'using %s should be greater than 1.5 trillion' do
  14. result = scope.function_strftime(['%s'])
  15. expect(result.to_i).to(be > 1_500_000_000)
  16. end
  17. it 'returns a date when given %Y-%m-%d' do
  18. result = scope.function_strftime(['%Y-%m-%d'])
  19. expect(result).to match(%r{^\d{4}-\d{2}-\d{2}$})
  20. end
  21. end