to_bytes_spec.rb 682 B

12345678910111213141516171819202122232425
  1. require 'spec_helper_acceptance'
  2. describe 'to_bytes function' do
  3. describe 'success' do
  4. pp = <<-DOC
  5. $o = to_bytes('4 kB')
  6. notice(inline_template('to_bytes is <%= @o.inspect %>'))
  7. DOC
  8. it 'converts kB to B' do
  9. apply_manifest(pp, :catch_failures => true) do |r|
  10. m = r.stdout.match(%r{to_bytes is (\d+)\D})
  11. expect(m[1]).to eq('4096')
  12. end
  13. end
  14. it 'works without the B in unit'
  15. it 'works without a space before unit'
  16. it 'works without a unit'
  17. it 'converts fractions'
  18. end
  19. describe 'failure' do
  20. it 'handles no arguments'
  21. it 'handles non integer arguments'
  22. it 'handles unknown units like uB'
  23. end
  24. end