Sha256: 42297bd3d8ee3bac7364f38e50e4a7e5a7bc59c851ebec02a2b1816a925a25e6
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Normalizy::Config, '#alias' do context 'with no raw type' do let!(:object) { User.new name: 'Washington Botelho' } before do object.class.normalizy_rules = {} Normalizy.configure do |config| config.alias :email, :downcase end end it 'alias one filter to others' do object.class.normalizy :name, with: :email object.save expect(object.name).to eq 'washington botelho' end end context 'with raw type' do let!(:object) { User.new amount: 'R$ 4.200,00' } before { object.class.normalizy_rules = {} } context 'configured on setup' do before do Normalizy.configure do |config| config.alias :money, :number, raw: true end end it 'alias one filter to others' do object.class.normalizy :amount, with: :money object.save expect(object.amount).to eq 420_000 end end context 'configured on normalizy' do before do Normalizy.configure do |config| config.alias :money, :number end end it 'alias one filter to others' do object.class.normalizy :amount, with: :money, raw: true object.save expect(object.amount).to eq 420_000 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
normalizy-0.1.0 | spec/normalizy/config/alias_spec.rb |