Add tests for integer and timestamp parsing
This commit is contained in:
parent
b34b18759f
commit
ef21f5c0d6
2 changed files with 36 additions and 0 deletions
|
|
@ -38,6 +38,14 @@ module DiasporaFederation
|
||||||
class TestEntityWithBoolean < DiasporaFederation::Entity
|
class TestEntityWithBoolean < DiasporaFederation::Entity
|
||||||
property :test, :boolean
|
property :test, :boolean
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class TestEntityWithInteger < DiasporaFederation::Entity
|
||||||
|
property :test, :integer
|
||||||
|
end
|
||||||
|
|
||||||
|
class TestEntityWithTimestamp < DiasporaFederation::Entity
|
||||||
|
property :test, :timestamp
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Validators
|
module Validators
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,34 @@ XML
|
||||||
}.to raise_error Entity::ValidationError, "missing required properties: test"
|
}.to raise_error Entity::ValidationError, "missing required properties: test"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "parses integer fields with a randomly matching pattern as erroneous" do
|
||||||
|
%w(1,2,3 foobar two).each do |weird_value|
|
||||||
|
xml = <<-XML.strip
|
||||||
|
<test_entity_with_integer>
|
||||||
|
<test>#{weird_value}</test>
|
||||||
|
</test_entity_with_integer>
|
||||||
|
XML
|
||||||
|
|
||||||
|
expect {
|
||||||
|
Entities::TestEntityWithInteger.from_xml(Nokogiri::XML::Document.parse(xml).root)
|
||||||
|
}.to raise_error Entity::ValidationError, "missing required properties: test"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "parses timestamp fields with a randomly matching pattern as erroneous" do
|
||||||
|
%w(foobar yesterday now 1.2.foo).each do |weird_value|
|
||||||
|
xml = <<-XML.strip
|
||||||
|
<test_entity_with_timestamp>
|
||||||
|
<test>#{weird_value}</test>
|
||||||
|
</test_entity_with_timestamp>
|
||||||
|
XML
|
||||||
|
|
||||||
|
expect {
|
||||||
|
Entities::TestEntityWithTimestamp.from_xml(Nokogiri::XML::Document.parse(xml).root)
|
||||||
|
}.to raise_error Entity::ValidationError, "missing required properties: test"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "nested entities" do
|
context "nested entities" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue