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

Nest responses should be stubbed #17

Open
stevenpetryk opened this issue Dec 17, 2014 · 5 comments
Open

Nest responses should be stubbed #17

stevenpetryk opened this issue Dec 17, 2014 · 5 comments

Comments

@stevenpetryk
Copy link
Collaborator

Currently, testing this gem requires users to have a physical Nest. This is annoying, because it means that the project would never be able to work with a continuous integration service. It also made it hard for me to create pull requests. The solution I used was to create fake devices using Nest's developer tools. This, however, is not an ideal workflow when developing a gem. Running rspec should work regardless of your machine's state.

The best solution is to mock Nest's API responses using rspec-mocks. I'll throw together a pull request when I get time. A nice bonus of doing specs this way is a vast speed improvement, since no network requests are required.

@ericboehs
Copy link
Owner

Another option is to use VCR. VCR can be disabled and allow network requests to pass through. This would allow us to easily ensure the Nest API hasn't changed just by flipping a bit (or maybe even a specialized rake task).

VCR also can prevent all network requests from happening (only using what requests it's previous recorded). The VCR fixtures (cassettes) could of course be generalized for public use.

Unfortunately this isn't a high priority for me right now but I'd love to see this implemented.

@stevenpetryk
Copy link
Collaborator Author

Unfortunately this isn't a high priority for me right now but I'd love to see this implemented.

Yeah, that's understandable. It's quite the undertaking. VCR looks super neat though, and could really come in handy here! I'll definitely check it out and see if I can get it working.

@freerobby
Copy link

@ericboehs How would you feel if I rewrote the tests to use the NEST Developer Tools chrome extension so that we can use a simulated thermostat but still ensure we are up to date with API specifications? If so, I may take a stab at this over the holiday break.

https://developer.nest.com/documentation/cloud/chrome-extension

@stevenpetryk
Copy link
Collaborator Author

How would you integrate the Nest Developer Tools with the gem itself? I mean, once you add a Thermostat to your account using the Dev Tools, the specs pass.

@freerobby
Copy link

@stevenpetryk Sorry, I didn't investigate in much detail and assumed everything ran locally in developer tools. I figured it would require Selenium, chromedriver or something of the sort for setup/teardown. If that's not the case, I'd just document how to get started that way if one doesn't want to use a physical Nest.

My motivation stems from #12, which adds support for multiple structures and devices. I'd really like to see that PR merged, and build on it and test multiple devices.

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

3 participants