Sha256: 57e97660262840c46355b7c7592fcc2c6458b515a2f4d42c88f6dae6623d57be

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

require 'minitest_helper'

describe Rasti::Types::IO do

  it 'nil -> nil' do
    Rasti::Types::IO.cast(nil).must_equal nil
  end

  [StringIO.new, File.new(__FILE__)].each do |value|
    it "#{value.inspect} -> #{value}" do
      Rasti::Types::IO.cast(value).must_equal value
    end
  end

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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rasti-types-2.0.1 spec/io_spec.rb
rasti-types-2.0.0 spec/io_spec.rb