Initial commit

This commit is contained in:
Yaser
2026-08-13 19:50:53 +03:30
commit 38084458fe
879 changed files with 95198 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
# encoding: UTF-8
# frozen_string_literal: true
class Validatable
include ActiveModel::Validations
attr_accessor :amount
validates :amount, precision: { less_than_or_eq_to: 2 }
end
describe PrecisionValidator do
subject { Validatable.new }
it 'returns valid record' do
subject.stubs(amount: 1)
expect(subject).to be_valid
end
it 'returns invalid record with errors' do
subject.stubs(amount: 0.001)
expect(subject).not_to be_valid
expect(subject.errors[:amount]).to include(/precision must be less than or equal to 2/)
end
it 'returns invalid record with errors' do
subject.stubs(amount: '0.001')
expect(subject).not_to be_valid
expect(subject.errors[:amount]).to include(/must be a number/)
end
end