Created
March 17, 2016 09:00
-
-
Save Integralist/72d1f0ab5155c1a27d3f 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