Sha256: 985f895e5b3c0ec3b6ffde388500aba6edfb276e0e782cbe8a8d4937f55883f9

Contents?: true

Size: 535 Bytes

Versions: 6

Compression:

Stored size: 535 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 { is_expected.to 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.2.1 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.2.0 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.1.3 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.1.2 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.1.1 spec/tty/shell/question/validation/coerce_spec.rb
tty-0.1.0 spec/tty/shell/question/validation/coerce_spec.rb