-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,6 +289,19 @@ | |
|
||
expect { define.() }.to raise_error(ArgumentError) | ||
end | ||
|
||
it 'raises error when trying to set missing attribute' do | ||
factories.define(:user, relation: :users) do |f| | ||
f.first_name 'Janis' | ||
f.last_name 'Miezitis' | ||
f.email 'janjiss@gmail.com' | ||
f.timestamps | ||
end | ||
|
||
expect { | ||
factories[:user, not_real_attribute: "invalid attribute value"] | ||
}.to raise_error(ROM::Factory::UnknownFactoryAttributes) | ||
end | ||
end | ||
|
||
context 'sequence' do | ||
|
@@ -647,7 +660,7 @@ | |
end | ||
|
||
it 'allows overrides' do | ||
user = factories[:user, name: "Joe"] | ||
user = factories[:user, first_name: "Joe"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
task = factories[:task, user: user] | ||
|
||
expect(task.title).to eql('A task') | ||
|
There was a problem hiding this comment.
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 thanRom::Factory::Builder::Persistable::UnknownFactoryAttributes