Sha256: 6646ffeb5437a24ac8b40fcb6a1f9b63399b1d1262fe546834f3ca6272d0105f

Contents?: true

Size: 749 Bytes

Versions: 6

Compression:

Stored size: 749 Bytes

Contents

module LazyValueExamples

  def lazy_value(key)
    Asynchronic::DataStore::LazyValue.new data_store, key
  end

  it 'Get' do
    value = lazy_value :key
    value.must_be_nil
    
    data_store[:key] =  1
    value.must_equal 1
  end

  it 'Reload' do
    value = lazy_value :key

    data_store[:key] =  1
    value.must_equal 1

    data_store[:key] =  2
    value.must_equal 1
    value.reload.must_equal 2
  end

  it 'Transparent proxy' do
    value = lazy_value :key
    data_store[:key] =  1
    value.must_be_instance_of Fixnum
    value.must_equal 1
  end

  it 'Inspect' do
    value = lazy_value :key
    value.inspect.must_match /#<Asynchronic::DataStore::LazyValue @data_store_class=.+ @data_store_connection=.+ @key=key>/
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
asynchronic-0.3.1 spec/data_store/lazy_value_examples.rb
asynchronic-0.3.0 spec/data_store/lazy_value_examples.rb
asynchronic-0.2.3 spec/data_store/lazy_value_examples.rb
asynchronic-0.2.2 spec/data_store/lazy_value_examples.rb
asynchronic-0.2.1 spec/data_store/lazy_value_examples.rb
asynchronic-0.2.0 spec/data_store/lazy_value_examples.rb