File: create.rb

package info (click to toggle)
ruby-moneta 1.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,776 kB
  • sloc: ruby: 13,201; sh: 178; makefile: 7
file content (25 lines) | stat: -rw-r--r-- 665 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
shared_examples :create do
  it 'creates the given key' do
    store.create('key','value').should be true
    store['key'].should == 'value'
  end

  it 'creates raw value with the given key' do
    store.raw.create('key','value').should be true
    store.raw['key'].should == 'value'
  end

  it 'does not create a key if it exists' do
    store['key'] = 'value'
    store.create('key','another value').should be false
    store['key'].should == 'value'
  end

  it 'supports Mutex' do
    a = Moneta::Mutex.new(store, 'mutex')
    b = Moneta::Mutex.new(store, 'mutex')
    a.lock.should be true
    b.try_lock.should be false
    a.unlock.should be_nil
  end
end