Sha256: 46f0cb3af0dc88e7b0e8f00fdfc613fa4ace3df2bf69801abd911c98a8e35e3a

Contents?: true

Size: 536 Bytes

Versions: 6

Compression:

Stored size: 536 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'spec_helper'

describe TTY::Shell::Question::Validation, '#coerce' do
  let(:validation) { "^[^\.]+\.[^\.]+" }
  let(:instance) { described_class.new }

  subject { instance.coerce validation }

  it { should be_kind_of Regexp }

  context 'when proc' do
   let(:validation) { lambda { "^[^\.]+\.[^\.]+" } }

    it { should be_kind_of Proc }
  end

  context 'when unkown type' do
    let(:validation) { Object.new }

    it { expect { subject }.to raise_error(TTY::ValidationCoercion) }
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tty-0.0.11 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.0.10 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.0.9 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.0.8 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.0.7 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.0.6 spec/tty/shell/question/validation/coerce_spec.rb