Sha256: f0e53233ed43ae060a4c27aec79212befd423f268b3bc5d26e98d97a320f48c8

Contents?: true

Size: 472 Bytes

Versions: 5

Compression:

Stored size: 472 Bytes

Contents

require 'spec_helper'

describe Virtus::Coercion::String, '.to_integer' do
  subject { described_class.to_integer(string) }

  { '1' => 1, '1.0' => 1, '.1' => 0 }.each do |value, expected|
    context "with #{value.inspect}" do
      let(:string) { value }

      it { should be_kind_of(Integer) }

      it { should eql(expected) }
    end
  end

  context 'with an invalid integer string' do
    let(:string) { 'non-integer' }

    it { should equal(string) }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
virtus-0.0.10 spec/unit/virtus/coercion/string/class_methods/to_integer_spec.rb
virtus-0.0.9 spec/unit/virtus/coercion/string/class_methods/to_integer_spec.rb
virtus-0.0.8 spec/unit/virtus/coercion/string/class_methods/to_integer_spec.rb
virtus-0.0.7 spec/unit/virtus/coercion/string/class_methods/to_integer_spec.rb
virtus-0.0.6 spec/unit/virtus/coercion/string/class_methods/to_integer_spec.rb