Raise ValidationError if properties are missing
This commit is contained in:
parent
56a649ac80
commit
4295237e9e
3 changed files with 3 additions and 3 deletions
|
|
@ -153,7 +153,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
def validate_missing_props(entity_data)
|
def validate_missing_props(entity_data)
|
||||||
missing_props = self.class.missing_props(entity_data)
|
missing_props = self.class.missing_props(entity_data)
|
||||||
raise ArgumentError, "missing required properties: #{missing_props.join(', ')}" unless missing_props.empty?
|
raise ValidationError, "missing required properties: #{missing_props.join(', ')}" unless missing_props.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def setable?(name, val)
|
def setable?(name, val)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ module DiasporaFederation
|
||||||
it "checks for required properties" do
|
it "checks for required properties" do
|
||||||
expect {
|
expect {
|
||||||
Entities::TestDefaultEntity.new({})
|
Entities::TestDefaultEntity.new({})
|
||||||
}.to raise_error ArgumentError, "missing required properties: test1, test2"
|
}.to raise_error Entity::ValidationError, "missing required properties: test1, test2"
|
||||||
end
|
end
|
||||||
|
|
||||||
context "defaults" do
|
context "defaults" do
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ shared_examples "an Entity subclass" do
|
||||||
|
|
||||||
describe "initialize" do
|
describe "initialize" do
|
||||||
it "must not create blank instances" do
|
it "must not create blank instances" do
|
||||||
expect { described_class.new({}) }.to raise_error ArgumentError
|
expect { described_class.new({}) }.to raise_error DiasporaFederation::Entity::ValidationError
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if nil was given" do
|
it "fails if nil was given" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue