Sha256: b41a6608d9114f7014f90dd67e5b79cde141c707989e1adf62727c672381a4cd

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe TTY::Conversion::IntegerConverter, '#convert' do
  let(:object) { described_class.new }
  let(:strict) { true }

  subject(:converter) { object.convert(value, strict) }

  context 'with empty' do
    let(:value) { '' }

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

  context 'with 1 as string' do
    let(:value) { '1' }

    it { is_expected.to eql 1 }
  end

  context 'with float' do
    let(:value) { 1.2 }

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

  context 'with float not strict' do
    let(:value) { 1.2 }
    let(:strict) { false }

    it { is_expected.to eql 1 }
  end

  context 'with letters not strict' do
    let(:value) { '1abc' }
    let(:strict) { false }

    it { is_expected.to eql 1 }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tty-0.1.1 spec/tty/conversion/converter/integer/convert_spec.rb