-
-
Notifications
You must be signed in to change notification settings - Fork 910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add decimal column type to numericality matcher #812
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,18 @@ def default_validation_values | |
to raise_error(described_class::IneffectiveTestError) | ||
end | ||
end | ||
|
||
context 'when the column is a decimal column' do | ||
it 'raises an IneffectiveTestError' do | ||
record = build_record_validating_numericality( | ||
column_type: :decimal | ||
) | ||
assertion = -> { expect(record).to validate_numericality } | ||
|
||
expect(&assertion). | ||
to raise_error(described_class::IneffectiveTestError) | ||
end | ||
end | ||
end | ||
|
||
context 'and not validating anything' do | ||
|
@@ -233,6 +245,17 @@ def default_validation_values | |
expect(record).to validate_numericality.odd | ||
end | ||
end | ||
|
||
context 'when the column is a decimal column' do | ||
it 'accepts (and does not raise an error)' do | ||
record = build_record_validating_numericality( | ||
column_type: :decimal, | ||
odd: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put a comma after the last parameter of a multiline method call. |
||
) | ||
|
||
expect(record).to validate_numericality.odd | ||
end | ||
end | ||
end | ||
|
||
context 'and not validating with odd' do | ||
|
@@ -276,6 +299,17 @@ def default_validation_values | |
expect(record).to validate_numericality.even | ||
end | ||
end | ||
|
||
context 'when the column is a decimal column' do | ||
it 'accepts (and does not raise an error)' do | ||
record = build_record_validating_numericality( | ||
column_type: :decimal, | ||
even: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put a comma after the last parameter of a multiline method call. |
||
) | ||
|
||
expect(record).to validate_numericality.even | ||
end | ||
end | ||
end | ||
|
||
context 'and not validating with even' do | ||
|
@@ -319,6 +353,17 @@ def default_validation_values | |
expect(record).to validate_numericality.is_less_than_or_equal_to(18) | ||
end | ||
end | ||
|
||
context 'when the column is a decimal column' do | ||
it 'accepts (and does not raise an error)' do | ||
record = build_record_validating_numericality( | ||
column_type: :decimal, | ||
less_than_or_equal_to: 18 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put a comma after the last parameter of a multiline method call. |
||
) | ||
|
||
expect(record).to validate_numericality.is_less_than_or_equal_to(18) | ||
end | ||
end | ||
end | ||
|
||
context 'and not validating with less_than_or_equal_to' do | ||
|
@@ -366,6 +411,17 @@ def default_validation_values | |
expect(record).to validate_numericality.is_less_than(18) | ||
end | ||
end | ||
|
||
context 'when the column is a decimal column' do | ||
it 'accepts (and does not raise an error)' do | ||
record = build_record_validating_numericality( | ||
column_type: :decimal, | ||
less_than: 18 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put a comma after the last parameter of a multiline method call. |
||
) | ||
|
||
expect(record).to validate_numericality.is_less_than(18) | ||
end | ||
end | ||
end | ||
|
||
context 'and not validating with less_than' do | ||
|
@@ -411,6 +467,17 @@ def default_validation_values | |
expect(record).to validate_numericality.is_equal_to(18) | ||
end | ||
end | ||
|
||
context 'when the column is a decimal column' do | ||
it 'accepts (and does not raise an error)' do | ||
record = build_record_validating_numericality( | ||
column_type: :decimal, | ||
equal_to: 18 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put a comma after the last parameter of a multiline method call. |
||
) | ||
|
||
expect(record).to validate_numericality.is_equal_to(18) | ||
end | ||
end | ||
end | ||
|
||
context 'and not validating with equal_to' do | ||
|
@@ -462,6 +529,19 @@ def default_validation_values | |
is_greater_than_or_equal_to(18) | ||
end | ||
end | ||
|
||
context 'when the column is a decimal column' do | ||
it 'accepts (and does not raise an error)' do | ||
record = build_record_validating_numericality( | ||
column_type: :decimal, | ||
greater_than_or_equal_to: 18 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put a comma after the last parameter of a multiline method call. |
||
) | ||
|
||
expect(record). | ||
to validate_numericality. | ||
is_greater_than_or_equal_to(18) | ||
end | ||
end | ||
end | ||
|
||
context 'not validating with greater_than_or_equal_to' do | ||
|
@@ -513,6 +593,19 @@ def default_validation_values | |
is_greater_than(18) | ||
end | ||
end | ||
|
||
context 'when the column is a decimal column' do | ||
it 'accepts (and does not raise an error)' do | ||
record = build_record_validating_numericality( | ||
column_type: :decimal, | ||
greater_than: 18 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put a comma after the last parameter of a multiline method call. |
||
) | ||
|
||
expect(record). | ||
to validate_numericality. | ||
is_greater_than(18) | ||
end | ||
end | ||
end | ||
|
||
context 'and not validating with greater_than' do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put a comma after the last parameter of a multiline method call.