Sha256: d556e903ea9a49029edda2f091723e0176dfe0d17edde80deff08ddb0bb3c589

Contents?: true

Size: 582 Bytes

Versions: 3

Compression:

Stored size: 582 Bytes

Contents

require 'spec_helper'

describe RailsSettingsUi::ValueTypes::Duration do
  describe "#cast" do
    it "should cast string to duration" do
      param = "#{5.hours}"
      fixnum_type = RailsSettingsUi::ValueTypes::Duration.new(param)
      expect(fixnum_type.cast).to eq(5.hours)
      expect(fixnum_type.cast).to be_instance_of(ActiveSupport::Duration)
    end
  end

  describe "if value not valid duration" do
    it "should be not valid" do
      fixnum_type = RailsSettingsUi::ValueTypes::Duration.new("one hour")
      expect(fixnum_type.valid?).to be_falsey
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-settings-ui-0.5.0 spec/lib/rails-settings-ui/value_types/duration_spec.rb
rails-settings-ui-0.4.0 spec/lib/rails-settings-ui/value_types/duration_spec.rb
rails-settings-ui-0.3.2 spec/lib/rails-settings-ui/value_types/duration_spec.rb