Sha256: 349e823a50dea2becba9ea199a91bae9c1636a404f4841b94c6bfcb7ae8d584f

Contents?: true

Size: 731 Bytes

Versions: 4

Compression:

Stored size: 731 Bytes

Contents

require 'minitest_helper'

describe Rasti::Types::Boolean do

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

  [false, 'false', 'False', 'FALSE', 'F'].each do |value|
    it "#{value.inspect} -> false" do
      Rasti::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::Types::Boolean.cast(value) }.must_raise Rasti::Types::CastError
      error.message.must_equal "Invalid cast: #{as_string(value)} -> Rasti::Types::Boolean"
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rasti-types-1.1.2 spec/boolean_spec.rb
rasti-types-1.1.1 spec/boolean_spec.rb
rasti-types-1.1.0 spec/boolean_spec.rb
rasti-types-1.0.0 spec/boolean_spec.rb