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

Check if stored_data is not empty before parsing it to json #408

Closed
wants to merge 3 commits into from

Conversation

JanStevens
Copy link

In light of issue #406

@bf4
Copy link
Collaborator

bf4 commented Aug 20, 2015

Is it possible that the bug is actually that stored_data should be nil not '' or "null" and that is a bug originated in how stored_data is generated? That said, the fix could also be if stored_data && !stored_data.empty?

@JanStevens
Copy link
Author

This largely depends on your JSON implementation, It seems that Oj for example returns nil in case stored_data is nil. Standaard JSON lib will raise a TypeError

I agree that the fix could also be to check if stored_data is not empty (which would make sense)

Regards

@JanStevens JanStevens changed the title Always return a hash so we dont fail when the file is not readable Check if stored_data is not empty before parsing it to json Aug 20, 2015
@bf4
Copy link
Collaborator

bf4 commented Aug 23, 2015

Would you mind rebasing your commits and adding a test for this?

@JanStevens
Copy link
Author

Looking at the test suite and current solutions I would say its already being tested:

I can add specific test to see that we always return an empty hash incase the file couldn't be read but the be_empty seems to be sufficient.

@JanStevens
Copy link
Author

Lets merge merge merge? xD

@xaviershay
Copy link
Collaborator

If it was already being tested, then why weren't those tests failing?

@xaviershay
Copy link
Collaborator

I'm not convinced this addresses the issue. If stored_data was empty the existing code still works (as per the specs you linked, and also by inspection - it will just iterate over an empty hash.) See comments on #406. Closing until someone convinces me otherwise.

@xaviershay xaviershay closed this Nov 28, 2015
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.

3 participants