Skip to content

Fix issue 5 #13

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

Merged
merged 3 commits into from
Feb 24, 2018
Merged

Fix issue 5 #13

merged 3 commits into from
Feb 24, 2018

Conversation

happycollision
Copy link
Contributor

See my thoughts in my last commit. I know this would have been massively helpful for me, so I chose to fix it in this way. I am open to changes.

Fixes jsonapi-suite#5 
`json_include` specifying an index where nothing exists was the underlying problem. I have chosen to throw an error in that case, because nobody ought to be *trying* to get `nil` from that method. Since we are testing, a nice error message would probably be helpful.

I also added an error class so that expectations in this repo testing that an error is thrown when it should be are less likely to give a false positive.
Copy link
Contributor

@richmolj richmolj left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this @happycollision, very much appreciate the help! Had one minor comment then this is good to go 👍

@@ -0,0 +1,2 @@
class JsonapiSpecHelpersError < StandardError
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make this

module JsonapiSpecHelpers
  module Errors
    class Base < StandardError
    class IncludeOutOfBounds < Base
  end
end

To set up a generic error handling pattern for the future? This is similar to what we have in compliable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All set. I am pretty inexperienced with Ruby, so I am glad you directed me to a better way of dealing with errors. I will be using that pattern in my own project as needed.

Sets up a module in the same fashion as the JsonapiCompliable gem
@richmolj richmolj merged commit 2ef4f0a into jsonapi-suite:master Feb 24, 2018
@richmolj
Copy link
Contributor

Thanks again @happycollission!

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