Sha256: 9ca40da5f15b64b7bb109497a623d16a6b35bf69987ef45a431a13143a454269
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe User, 'filters:percent' do before do described_class.normalizy_rules = {} end specify do described_class.normalizy :amount_text, with: :percent expect(described_class.create(amount_text: '42.00 %').amount_text).to eq '42.00' expect(described_class.create(amount_text: '42.10 %').amount_text).to eq '42.10' end specify do described_class.normalizy :amount_cents, with: { percent: { type: :cents } } expect(described_class.create(amount_cents: '42.33 %').amount_cents).to be 4233 end specify do described_class.normalizy :amount_cents, with: { percent: { cast: :to_i } } expect(described_class.create(amount_cents: '42.00 %').amount_cents).to be 42 end specify do described_class.normalizy :amount, with: { percent: { cast: :to_d } } expect(described_class.create(amount: '1.23 %').amount).to eq 1.23.to_d end specify do described_class.normalizy :amount, with: { percent: { cast: :to_f, type: :cents } } expect(described_class.create(amount: '42.00 %').amount).to eq 4200.0.to_f end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
normalizy-0.2.0 | spec/normalizy/extensions/filters/percent_spec.rb |