Skip to content

Instantly share code, notes, and snippets.

@eknuth
Created December 17, 2011 17:31
Show Gist options
  • Save eknuth/1490817 to your computer and use it in GitHub Desktop.
Save eknuth/1490817 to your computer and use it in GitHub Desktop.
setting up the environment
# install node
brew install node
# install redis
brew install redis
# install npm
curl http://npmjs.org/install.sh | sh
# install mocha and should for testing
npm install mocha should -g
# install node-redis to talk with redis
npm install redis
# create the first test
mkdir test
touch test/test_redis.js
var redis = require("redis"),
should = require('should'),
client = redis.createClient();
describe('strings in redis', function() {
var keyToSet = 'bingo',
valueToSet = 'the dog';
describe('#set()', function() {
it('should save without error', function(done) {
client.set(keyToSet, valueToSet, done);
});
});
describe('#get()', function() {
it('should be able to get the value we set', function(done) {
client.get(keyToSet, function(err, data) {
should.not.exist(err);
data.should.equal(valueToSet);
done();
});
});
});
});
var redis = require("redis"),
should = require('should'),
client = redis.createClient();
describe('strings in redis', function() {
var keyToSet = 'bingo',
valueToSet = 'the dog';
describe('#set()', function() {
it('should save without error', function(done) {
client.set(keyToSet, valueToSet, done);
});
});
describe('#get()', function() {
it('should be able to get the value we set', function(done) {
client.get(keyToSet, function(err, data) {
should.not.exist(err);
data.should.equal(valueToSet);
done();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment