Sha256: d18e46d7eddabafde7450d591889b5c66b65c966d0b826912c517bfef60c2c94

Contents?: true

Size: 823 Bytes

Versions: 4

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ModelPercent, 'filters:percent' do
  specify 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

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

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

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

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

  specify 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.1.1 spec/normalizy/extensions/filters/percent_spec.rb
normalizy-1.1.0 spec/normalizy/extensions/filters/percent_spec.rb
normalizy-1.0.1 spec/normalizy/extensions/filters/percent_spec.rb
normalizy-1.0.0 spec/normalizy/extensions/filters/percent_spec.rb