Sha256: 11b274f64b644ae6b8bb73ddd066d63b21f2c56590e243d4e4138e9f5bc94ee4
Contents?: true
Size: 1.73 KB
Versions: 6
Compression:
Stored size: 1.73 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Normalizy::Filters::Number do context 'with no cast' do it { expect(subject.call('abcdefghijklmnopkrstuvxyz')).to eq nil } it { expect(subject.call('ABCDEFGHIJKLMNOPKRSTUVXYZ')).to eq nil } it { expect(subject.call('áéíóúàâêôãõ')).to eq nil } it { expect(subject.call('0123456789')).to eq '0123456789' } it { expect(subject.call('012345x6789')).to eq '0123456789' } it { expect(subject.call("\n")).to eq nil } it { expect(subject.call(42)).to eq 42 } it { expect(subject.call(nil)).to eq nil } it { expect(subject.call('nil')).to eq nil } it { expect(subject.call('')).to eq nil } end context 'with :cast' do it { expect(subject.call('abcdefghijklmnopkrstuvxyz', cast: :to_i)).to eq nil } it { expect(subject.call('ABCDEFGHIJKLMNOPKRSTUVXYZ', cast: :to_i)).to eq nil } it { expect(subject.call('áéíóúàâêôãõ', cast: :to_i)).to eq nil } it { expect(subject.call('0123456789', cast: :to_i)).to eq 123_456_789 } it { expect(subject.call('012345x6789', cast: :to_i)).to eq 123_456_789 } it { expect(subject.call("\n", cast: :to_i)).to eq nil } it { expect(subject.call(42, cast: :to_i)).to eq 42 } it { expect(subject.call(nil, cast: :to_i)).to eq nil } it { expect(subject.call('nil', cast: :to_i)).to eq nil } it { expect(subject.call('', cast: :to_i)).to eq nil } end end
Version data entries
6 entries across 6 versions & 1 rubygems