Sha256: 89d82db027be98924ee93086fe7ec8566d5e839601c4f934fa17623eca0219b7

Contents?: true

Size: 793 Bytes

Versions: 4

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ModelPercent, 'filters:percent' do
  it do
    expect(described_class.create(text: '42.00 %').text).to eq '42.00'
    expect(described_class.create(text: '42.10 %').text).to eq '42.10'
  end

  it do
    expect(described_class.create(cents_type: '42.33 %').cents_type).to eq '4233'
  end

  it do
    expect(described_class.create(cast_to_i: '42.00 %').cast_to_i).to be 42
  end

  it do
    expect(described_class.create(cast_to_d: '1.23 %').cast_to_d).to eq 1.23
  end

  it do
    expect(described_class.create(cents_type_and_cast_to_f: '42.00 %').cents_type_and_cast_to_f).to eq 4200.0
  end

  it do
    expect(described_class.create(cents_type_and_cast_to_i: '42.00 %').cents_type_and_cast_to_i).to eq 4200
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
normalizy-1.5.0 spec/normalizy/extensions/filters/percent_spec.rb
normalizy-1.4.0 spec/normalizy/extensions/filters/percent_spec.rb
normalizy-1.3.0 spec/normalizy/extensions/filters/percent_spec.rb
normalizy-1.2.0 spec/normalizy/extensions/filters/percent_spec.rb