Sha256: 9cf96cfa10d6f6beb3fe82a5a5e31fc9eba3f4a796854ef1f1ecbd8d7e0f0e99
Contents?: true
Size: 1.13 KB
Versions: 26
Compression:
Stored size: 1.13 KB
Contents
require 'spec_helper' describe "#hsetnx(key, field)" do before do @key = "mock-redis-test:hsetnx" end it "returns true if the field is absent" do @redises.hsetnx(@key, 'field', 'val').should be_true end it "returns 0 if the field is present" do @redises.hset(@key, 'field', 'val') @redises.hsetnx(@key, 'field', 'val').should be_false end it "leaves the field unchanged if the field is present" do @redises.hset(@key, 'field', 'old') @redises.hsetnx(@key, 'field', 'new') @redises.hget(@key, 'field').should == 'old' end it "sets the field if the field is absent" do @redises.hsetnx(@key, 'field', 'new') @redises.hget(@key, 'field').should == 'new' end it "creates a hash if there is no such field" do @redises.hsetnx(@key, 'field', 'val') @redises.hget(@key, 'field').should == 'val' end it "stores values as strings" do @redises.hsetnx(@key, "num", 1) @redises.hget(@key, 'num').should == "1" end it "stores fields as strings" do @redises.hsetnx(@key, 1, "one") @redises.hget(@key, "1").should == "one" end it_should_behave_like "a hash-only command" end
Version data entries
26 entries across 26 versions & 1 rubygems