Sha256: 6fdbc4ce237f9df6e6e1f930ee191b20aa96456b3cdae389366b3474b20707db

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

require 'minitest_helper'

describe Rasti::Form::Types::Regexp do

  ['[a-z]', /[a-z]/].each do |value|
    it "#{value.inspect} -> #{Regexp.new(value).inspect}" do
      Rasti::Form::Types::Regexp.cast(value).must_equal Regexp.new(value)
    end
  end

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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rasti-form-3.0.0 spec/types/regexp_spec.rb