-
-
Save 3014zhangshuo/298226cbe29bc3f07dd9c20e343e87b0 to your computer and use it in GitHub Desktop.
Ruby Mock Redis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in your spec helper... | |
require "pry" | |
require "redis" | |
require "mock_redis" | |
RSpec.configure do |config| | |
config.before(:each) do | |
mock_redis = MockRedis.new | |
allow(Redis).to receive(:new).and_return(mock_redis) | |
end | |
end | |
# Also you can do... | |
require 'mock_redis' | |
>> mr = MockRedis.new | |
>> mr.set('some key', 'some value') | |
=> "OK" | |
>> mr.get('some key') | |
=> "some value" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment