Sha256: 707740f117c5d4bd0be2b07f8aca6530a016058fd58738797be61ec483d6cb4b
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'spec_helper' describe Structor::Type do it 'checks type' do expect(Structor::Type.new(Array).check([])).to be_true expect(Structor::Type.new(Fixnum).check(1)).to be_true expect(Structor::Type.new(Hash).check([])).to be_false expect(Structor::Type.new(TrueClass).check(false)).to be_false end it 'maps symbol to type' do expect(Structor::Type.new(:string).check('test')).to be_true expect(Structor::Type.new(:hash).check({})).to be_true expect(Structor::Type.new(:array).check([])).to be_true expect(Structor::Type.new(:number).check(42)).to be_true expect(Structor::Type.new(:number).check(-1.01)).to be_true expect(Structor::Type.new(:boolean).check(true)).to be_true expect(Structor::Type.new(:boolean).check(false)).to be_true end it 'checks for multiple types' do expect(Structor::Type.new([Array, :hash]).check([])).to be_true expect(Structor::Type.new([Array, :hash]).check({})).to be_true expect(Structor::Type.new([TrueClass, FalseClass]).check(true)).to be_true expect(Structor::Type.new([TrueClass, FalseClass]).check(false)).to be_true end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
structor-0.0.1 | spec/type_spec.rb |