spec/normalizy/config/alias_spec.rb in normalizy-0.1.0 vs spec/normalizy/config/alias_spec.rb in normalizy-0.2.0

- old
+ new

@@ -22,42 +22,36 @@ expect(object.name).to eq 'washington botelho' end end context 'with raw type' do - let!(:object) { User.new amount: 'R$ 4.200,00' } + before { User.normalizy_rules = {} } - before { object.class.normalizy_rules = {} } - context 'configured on setup' do before do Normalizy.configure do |config| - config.alias :money, :number, raw: true + config.alias :age, :number, raw: true end end it 'alias one filter to others' do - object.class.normalizy :amount, with: :money + User.normalizy :age, with: :age - object.save - - expect(object.amount).to eq 420_000 + expect(User.create(age: '= 42').age).to eq 42 end end context 'configured on normalizy' do before do Normalizy.configure do |config| - config.alias :money, :number + config.alias :age, :number end end it 'alias one filter to others' do - object.class.normalizy :amount, with: :money, raw: true + User.normalizy :age, with: :age, raw: true - object.save - - expect(object.amount).to eq 420_000 + expect(User.create(age: '= 42').age).to eq 42 end end end end