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

Raise error when trying to set missing attribute #45

Merged
merged 1 commit into from
Aug 12, 2019
Merged

Raise error when trying to set missing attribute #45

merged 1 commit into from
Aug 12, 2019

Conversation

rawburt
Copy link
Contributor

@rawburt rawburt commented Jul 5, 2019

I always typo some attribute name when using a factory. rom-factory ignores these typos. This PR makes rom-factory raise an error instead of the currently "ignore all the things" functionality.

I am not sure if this is the best way to solve this problem but "it works" 🤷‍♂

@@ -647,7 +660,7 @@
end

it 'allows overrides' do
user = factories[:user, name: "Joe"]
user = factories[:user, first_name: "Joe"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the exact kind of typo I would like to see an error for. I updated name to be first_name but we can just as easily make this be user = factories[:user]. I was not sure what the intent was for updating the name attribute considering there is no specific test that checks the update.

@@ -7,5 +7,11 @@ def initialize(name)
super("Factory +#{name}+ not defined")
end
end

class UnknownFactoryAttributes < StandardError
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I felt like ROM::Factory::UnknownFactoryAttributes was a bit nicer for the user to see than Rom::Factory::Builder::Persistable::UnknownFactoryAttributes

@solnic solnic merged commit 5888f07 into rom-rb:master Aug 12, 2019
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.

None yet

2 participants