Sha256: ccf6f8664b8d07beab72c7e7fd8d20852480d82e46ad8ebab449ce5da8af644d

Contents?: true

Size: 591 Bytes

Versions: 3

Compression:

Stored size: 591 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).source
    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

3 entries across 3 versions & 1 rubygems

Version Path
rasti-form-3.1.2 spec/types/regexp_spec.rb
rasti-form-3.1.1 spec/types/regexp_spec.rb
rasti-form-3.1.0 spec/types/regexp_spec.rb