Sha256: 034d4a3d9dd67144076fe31b06d2f8383a196c4662ec7b191b1e07fcea54fab5

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require "spec_helper"

describe Rico::Value do
  before :each do
    RiakHelpers.reset!
  end

  describe "#exists?" do
    it "returns true if it exists" do
      a = Rico::Value.new RiakHelpers.bucket, "value_exists_true"
      a.set "bob"
      b = Rico::Value.new RiakHelpers.bucket, "value_exists_true"
      b.exists?.should eql true
    end

    it "returns false if it does not exists" do
      a = Rico::Value.new RiakHelpers.bucket, "value_exists_false"
      a.exists?.should eql false
    end
  end

  describe "#get" do
    it "returns the value" do
      a = Rico::Value.new RiakHelpers.bucket, "value_get_return_value"
      a.set([1, 2, 3, 4, 5, "bob", "joe"])
      b = Rico::Value.new RiakHelpers.bucket, "value_get_return_value"
      b.get.should eql [1, 2, 3, 4, 5, "bob", "joe"]
    end

    it "returns nil if the value does not exist" do
      a = Rico::Value.new RiakHelpers.bucket, "value_get_nil"
      a.get.should eql nil
    end
  end

  describe "#set" do
    it "writes the value" do
      a = Rico::Value.new RiakHelpers.bucket, "value_set"
      a.set "john"
      b = Rico::Value.new RiakHelpers.bucket, "value_set"
      b.get.should eql "john"
    end
  end

  describe "#delete" do
    it "deletes an existing object" do
      a = Rico::Value.new RiakHelpers.bucket, "delete_existing"
      a.set "john"
      a.delete
      b = Rico::Value.new RiakHelpers.bucket, "delete_existing"
      b.exists?.should eql false
      b.get.should eql nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rico-0.0.1 spec/value_spec.rb