How to stub a method that is called from an outer scope to the function under test?
问题 I have a Redis client that is created thus using the node_redis library (https://github.com/NodeRedis/node_redis): var client = require('redis').createClient(6379, 'localhost'); I have a method I want to test whose purpose is to set and publish a value to Redis, so I want to test to ensure the set and publish methods are called or not called according to my expectations. The tricky thing is I want this test to work without needing to fire up an instance of a Redis server, so I can't just