1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
Expectations do
expect "message" do
errors = Validatable::Errors.new
errors.add(:attribute, "message")
errors.on(:attribute)
end
expect ["message"] do
errors = Validatable::Errors.new
errors.add(:attribute, "message")
errors.raw(:attribute)
end
expect "something new" do
errors = Validatable::Errors.new
errors.add(:attribute, "something old")
errors.replace(:attribute, ["something new"])
errors.on(:attribute)
end
expect "Capitalized word" do
errors = Validatable::Errors.new
errors.humanize("capitalized_word")
end
expect "Capitalized word without" do
errors = Validatable::Errors.new
errors.humanize("capitalized_word_without_id")
end
expect ["A humanized message", "a base message"] do
errors = Validatable::Errors.new
errors.add(:base, "a base message")
errors.add(:a_humanized, "message")
errors.full_messages.sort
end
expect true do
Validatable::Errors.included_modules.include?(Enumerable)
end
expect ["message1", "message2"] do
errors = Validatable::Errors.new
errors.add(:attribute, "message1")
errors.add(:attribute, "message2")
errors.on(:attribute)
end
expect 2 do
errors = Validatable::Errors.new
errors.add(:attribute, "message1")
errors.add(:attribute, "message2")
errors.count
end
expect 2 do
errors = Validatable::Errors.new
errors.add(:attribute1, "message1")
errors.add(:attribute2, "message2")
errors.count
end
end
|