Let's delve deeper into hooks and mocks. There are at least two related features that would be nice to have in WeatherQuery
:
As you can see, both of these features require us to set up a certain state before we can test them. In this case, we want to avoid mocking the actual state changes, because we would then have little or nothing to test. We can mock HTTP requests and other details not related to the state change, but we want to actually perform multiple queries and then make an assertion, rather than mock a state when multiple queries have been made. For example, if we are testing a method such as WeatherQuery.api_request_count
without actually making requests, we would mock an instance variable (or other internal counter store) and check that the method returned the mock...