Sha256: 0e40da1e866571b2e4a0a3cff431562ac7c36d33c97568f7a5de5655aee18ca0

Contents?: true

Size: 762 Bytes

Versions: 14

Compression:

Stored size: 762 Bytes

Contents

require 'minitest_helper'

describe Rasti::Form::Types::Boolean do
  
  [true, 'true', 'True', 'TRUE', 'T'].each do |value|
    it "#{value.inspect} -> true" do
      Rasti::Form::Types::Boolean.cast(value).must_equal true
    end
  end

  [false, 'false', 'False', 'FALSE', 'F'].each do |value|
    it "#{value.inspect} -> false" do
      Rasti::Form::Types::Boolean.cast(value).must_equal false
    end
  end

  [nil, 'text', 123, :false, :true, Time.now, [1,2], {a: 1, b: 2}, Object.new].each do |value|
    it "#{value.inspect} -> CastError" do
      error = proc { Rasti::Form::Types::Boolean.cast(value) }.must_raise Rasti::Form::CastError
      error.message.must_equal "Invalid cast: #{as_string(value)} -> Rasti::Form::Types::Boolean"
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rasti-form-3.1.2 spec/types/boolean_spec.rb
rasti-form-3.1.1 spec/types/boolean_spec.rb
rasti-form-3.1.0 spec/types/boolean_spec.rb
rasti-form-3.0.0 spec/types/boolean_spec.rb
rasti-form-2.2.0 spec/types/boolean_spec.rb
rasti-form-2.1.0 spec/types/boolean_spec.rb
rasti-form-2.0.0 spec/types/boolean_spec.rb
rasti-form-1.1.1 spec/types/boolean_spec.rb
rasti-form-1.1.0 spec/types/boolean_spec.rb
rasti-form-1.0.3 spec/types/boolean_spec.rb
rasti-form-1.0.2 spec/types/boolean_spec.rb
rasti-form-1.0.1 spec/types/boolean_spec.rb
rasti-form-1.0.0 spec/types/boolean_spec.rb
rasti-form-0.1.0 spec/types/boolean_spec.rb