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

DateTime is not considered a supported value #29

Open
esjee opened this issue Nov 9, 2017 · 1 comment
Open

DateTime is not considered a supported value #29

esjee opened this issue Nov 9, 2017 · 1 comment

Comments

@esjee
Copy link
Contributor

esjee commented Nov 9, 2017

Hey! I recently ran into the "issue" where doing an expectation like this:

# record = ...
# ^ some active record object 
expected_response = {
  updated_at: record.updated_at
}
expect(response.body).to include_json expected_response

which raises

     NotImplementedError:
       2017-11-13 13:37:00 UTC expectation is not supported

the fix here is to use .as_json, like so:

# record = ...
# ^ some active record object 
expected_response = {
  updated_at: record.updated_at.as_json
}
expect(response.body).to include_json expected_response

For what it's worth, it seems that datetimes are serialized to datetime strings in the Zulu timezone.

I was wondering if you (or others!) would find it useful to automagically detect datetimes like this in the provided expected json, and run as_json on any datetime objects encountered.

@waterlink
Copy link
Owner

What if we take it further and detect things that have a as_json method defined on them, and try to use that?

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

No branches or pull requests

2 participants