Skip to content
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

V3 abstract_resource beef up #19

Merged
merged 10 commits into from
Jul 8, 2017
Merged

Conversation

ndushay
Copy link

@ndushay ndushay commented Jul 7, 2017

setting up abstract_resource to do more heavy lifting for keys/properties that are used by multiple subclasses

I think this is simple enough that one reviewer is enough.

@ndushay ndushay force-pushed the v3-abstract-resource-beef-up branch from 3a442bd to 2ebd24b Compare July 7, 2017 21:06
@ndushay ndushay changed the title V3 abstract resource beef up V3 abstract_resource beef up Jul 7, 2017
Copy link
Member

@jmartin-sul jmartin-sul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left one question, and one nitpick (repeated, but same across instances). but 👍 overall.

the question is the one inline about the _PROPERTIES, possibly just me not understanding the usage.

re: the nitpick: my general preference is to not specify an exception class when expecting that an error isn't thrown, unless you know an error will be thrown, and you're just making sure it's not of a specific type. but it looks like the cases i pointed out are cases of valid usage, where you'd expect execution without error? anyway, not something that i feel super strongly about, and i'd merge as-is if you really prefer the current approach.

end
it 'does not raise error for entry that contains exactly "label" and "value"' do
subject['metadata'] = [{ 'label' => 'bar', 'value' => 'foo' }]
expect { subject.validate }.not_to raise_error(IIIF::V3::Presentation::IllegalValueError)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about just expect { subject.validate }.not_to raise_error?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure - that's fine by me. Will change

end
it 'does not raise error for entry with "id" and "type"' do
subject['thumbnail'] = [{ 'id' => 'bar', 'type' => 'foo', 'random' => 'xxx' }]
expect { subject.validate }.not_to raise_error(IIIF::V3::Presentation::IllegalValueError)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto on not looking for a specific exception class

describe 'nav_date' do
it 'does not raise error for value of form YYYY-MM-DDThh:mm:ssZ' do
subject['nav_date'] = '1991-01-02T13:04:27Z'
expect { subject.validate }.not_to raise_error(IIIF::V3::Presentation::IllegalValueError)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto on not looking for a specific exception class

end
it 'does not raise error for entry with "id" that is URI' do
subject['rights'] = [{ 'id' => 'http://example.org/rights', 'format' => 'text/html' }]
expect { subject.validate }.not_to raise_error(IIIF::V3::Presentation::IllegalValueError)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto on not looking for a specific exception class

end
it 'does not raise error for entry with "label" and "format"' do
subject['rendering'] = [{ 'label' => 'bar', 'format' => 'foo', 'random' => 'xxx' }]
expect { subject.validate }.not_to raise_error(IIIF::V3::Presentation::IllegalValueError)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto on not looking for a specific exception class

CONTENT_RESOURCE_PROPERTIES = %w{ format height width duration }

# used by Collection, AnnotationCollection
PAGING_PROPERTIES = %w{ first last next prev total start_index }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing seems to use these new _PROPERTIES keys, though there is suggested usage below... are these something that will be used in the future? by consumers of the gem? something used by some meta-programming magic that i'm not seeing/understanding?

Copy link
Author

@ndushay ndushay Jul 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these will be used by subclasses to make it a lot easier to specify prohibited_keys. The spec is full of language like "Other resource types must not have a xxx" and these are two groups of properties that are basically used together, or at least in the same way.

@jmartin-sul jmartin-sul merged commit 0f1bb36 into development Jul 8, 2017
@jmartin-sul jmartin-sul deleted the v3-abstract-resource-beef-up branch July 8, 2017 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants