Sha256: e60639a83b1f0af92d3f02f91b2281abaead4b14679e682846b9b1a501212741

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path("../support", __FILE__)

require "active_model"

class TypeArrayTest < CouchbaseOrm::Base
    attribute :name
    attribute :tags, :array, type: :string
    attribute :milestones, :array, type: :date
    attribute :flags, :array, type: :boolean
    attribute :things
end

describe CouchbaseOrm::Base do
    it "should be able to store and retrieve an array of strings" do
        obj = TypeArrayTest.new
        obj.tags = ["foo", "bar"]
        obj.save!

        obj = TypeArrayTest.find(obj.id)
        expect(obj.tags).to eq ["foo", "bar"]
    end

    it "should be able to store and retrieve an array of date" do
        dates = [Date.today, Date.today + 1]
        obj = TypeArrayTest.new
        obj.milestones = dates
        obj.save!

        obj = TypeArrayTest.find(obj.id)
        expect(obj.milestones).to eq dates
    end

    it "should be able to store and retrieve an array of boolean" do
        flags = [true, false]
        obj = TypeArrayTest.new
        obj.flags = flags
        obj.save!

        obj = TypeArrayTest.find(obj.id)
        expect(obj.flags).to eq flags
    end

    it "should be able to store and retrieve an array of basic objects" do
        things = [1, "1234", {"key" => 4}]
        obj = TypeArrayTest.new
        obj.things = things
        obj.save!

        obj = TypeArrayTest.find(obj.id)
        expect(obj.things).to eq things
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
couchbase-orm-2.0.4 spec/type_array_spec.rb
couchbase-orm-2.0.3 spec/type_array_spec.rb
couchbase-orm-2.0.2 spec/type_array_spec.rb
couchbase-orm-2.0.1 spec/type_array_spec.rb
couchbase-orm-2.0.0 spec/type_array_spec.rb