<commit_before>require "helper"

describe Redis::Lock, redis: true do

  before do
    @it = Redis::Lock.new( redis, "test" )
  end

  it "can acquire and release a lock" do
    redis.lock("test") { true }
    expect { redis.lock("test") { true } }.to_not raise_exception
    expect { redis.lock("test") { true } }.to_not raise_exception
  end


  it "can use a timeout" do
    @it.with_timeout(1) { true }.should be_true
    @it.with_timeout(1) { false }.should be_false
    results = [ false, false, true ]
    @it.with_timeout(1) { results.shift }.should be_true
  end

end
<commit_msg>Add a spec to test redis.<commit_after>require "helper"

describe Redis::Lock, redis: true do

  before do
    @it = Redis::Lock.new( redis, "test" )
  end

  it "can acquire and release a lock" do
    redis.lock("test") { true }
    expect { redis.lock("test") { true } }.to_not raise_exception
    expect { redis.lock("test") { true } }.to_not raise_exception
  end


  it "can use a timeout" do
    @it.with_timeout(1) { true }.should be_true
    @it.with_timeout(1) { false }.should be_false
    results = [ false, false, true ]
    @it.with_timeout(1) { results.shift }.should be_true
  end

  it "can use msetnx" do
    redis.msetnx "one", "uno", "two", "dos"
    redis.get("one").should eq("uno")
    redis.get("two").should eq("dos")
  end

end

{'fraction_non_alphanumeric': 0.14083457526080476, 'fraction_numerical': 0.004470938897168405, 'mean_word_length': 3.196875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1744473', 'n_tokens_mistral': 500, 'n_tokens_neox': 486, 'n_words': 138}