mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
add examples for custom_error_messages and interpolation values. what can I say? TATFT
This commit is contained in:
parent
525b3b9941
commit
b632093ce2
@ -363,6 +363,32 @@ describe ValidatesTimeliness::Validator do
|
||||
end
|
||||
end
|
||||
|
||||
describe "custom_error_messages" do
|
||||
it "should return hash of custom error messages from configuration with _message truncated from keys" do
|
||||
configure_validator(:type => :date, :invalid_date_message => 'thats no date')
|
||||
validator.send(:custom_error_messages)[:invalid_date].should == 'thats no date'
|
||||
end
|
||||
|
||||
it "should return empty hash if no custom error messages in configuration" do
|
||||
configure_validator(:type => :date)
|
||||
validator.send(:custom_error_messages).should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "interpolation_values" do
|
||||
it "should return hash of interpolation keys with restriction values" do
|
||||
before = '1900-01-01'
|
||||
configure_validator(:type => :date, :before => before)
|
||||
validator.send(:interpolation_values, :before, before.to_date).should == {:restriction => before}
|
||||
end
|
||||
|
||||
it "should return empty hash if no interpolation keys are in message" do
|
||||
before = '1900-01-01'
|
||||
configure_validator(:type => :date, :before => before, :before_message => 'too late')
|
||||
validator.send(:interpolation_values, :before, before.to_date).should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "restriction errors" do
|
||||
before :each do
|
||||
configure_validator(:type => :date, :before => lambda { raise })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user