Sha256: 5cef07152086a1ea2d7311fab45d2c66e29274bdaaefab289d9ca3ab1ad09058

Contents?: true

Size: 980 Bytes

Versions: 3

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

require_relative "../../../test_helper"

describe Eye::Patch::ValueParser do
  it "parses time values" do
    assert_equal 2.weeks, Eye::Patch::ValueParser.parse("2 weeks")
    assert_equal 1.5.hours, Eye::Patch::ValueParser.parse("1.5 hours")
    assert_equal 50.minutes, Eye::Patch::ValueParser.parse("50 minutes")
    assert_equal 3.seconds, Eye::Patch::ValueParser.parse("3 seconds")
  end

  it "parses size values" do
    assert_equal 3.2.gigabytes, Eye::Patch::ValueParser.parse("3.2 gigabytes")
    assert_equal 2.4.megabytes, Eye::Patch::ValueParser.parse("2.4 megabytes")
    assert_equal 1.kilobyte, Eye::Patch::ValueParser.parse("1 kilobyte")
    assert_equal 1.terabyte, Eye::Patch::ValueParser.parse("1 terabyte  ")
  end

  it "uses whitespace as word boundary characters" do
    assert_equal "second-thing", Eye::Patch::ValueParser.parse("second-thing")
    assert_equal "minutes", Eye::Patch::ValueParser.parse("minutes")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eye-patch-1.1.0 test/lib/eye/patch/value_parser_test.rb
eye-patch-1.0.1 test/lib/eye/patch/value_parser_test.rb
eye-patch-1.0.0 test/lib/eye/patch/value_parser_test.rb