shared_examples :transform_value do
  describe 'with the :raw option' do
    it 'can load without transforming the value' do
      moneta_property_of(values: 1).check do |values:|
        store['key'] = values[0]
        load_value(store.load('key', raw: true)).should == values[0]
      end
    end

    it 'can store without transforming the value' do
      moneta_property_of(values: 1).check do |values:|
        store['key'] = values[0]
        store.store('key', store.load('key', raw: true), raw: true)
        store.load('key').should == values[0]
      end
    end

    it 'can delete without transforming the value' do
      moneta_property_of(values: 1).check do |values:|
        store['key'] = values[0]
        load_value(store.delete('key', raw: true)).should == values[0]
      end
    end
  end

  it 'allows to bypass transformer with raw syntactic sugar' do
    store['key'] = 'value'
    load_value(store.raw.load('key')).should == 'value'

    store.raw.store('key', 'value')
    store.raw['key'].should == 'value'
    store.raw.load('key').should == 'value'
    store.raw.delete('key').should == 'value'

    store.raw['key'] = 'value2'
    store.raw['key'].should == 'value2'
  end
end
