Sha256: 49580d658c0f592ab2c41df447d269ff3d62fd3890a7e5be719b5259419a5325

Contents?: true

Size: 1.89 KB

Versions: 3

Compression:

Stored size: 1.89 KB

Contents

# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

require 'relaxo/model'

class Aggregate
	include Relaxo::Model
	
	property :id, UUID
	property :array_value
	property :hash_value
end

RSpec.describe Relaxo::Model::Document do
	let(:database_path) {File.join(__dir__, 'test')}
	let(:database) {Relaxo.connect(database_path)}
	
	let(:document_path) {'test/document.json'}
	
	before(:each) {FileUtils.rm_rf(database_path)}
	
	it "should create and save document" do
		model = Aggregate.create(database.current,
			array_value: [1, 2, 3],
			hash_value: {x: 10, y: 20}
		)
		
		database.commit(message: "Adding test model") do |dataset|
			model.save(dataset)
		end
		
		# Force all attributes to be reloaded from the object store:
		model.reload
		
		expect(model.array_value).to be_kind_of Array
		expect(model.hash_value).to be_kind_of Hash
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
relaxo-model-0.17.1 spec/relaxo/model/attribute_spec.rb
relaxo-model-0.17.0 spec/relaxo/model/attribute_spec.rb
relaxo-model-0.16.0 spec/relaxo/model/attribute_spec.rb