Sha256: e7809b4ad2857cbae3e1729a8972782c5e04de55072a2ed0a99874cd0e87b054

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'
describe Dbla::Document do
	before(:all) do
		class DocumentRig
			include Blacklight::Solr::Document
			include Dbla::Document
		end 
	end
	after(:all) do
		Object.send :remove_const, :DocumentRig
	end
	subject { DocumentRig.new(data) }
	context "flat fields" do
		let(:data) { {'foo' => 'bar', 'lol' => ['wut', 'no']} }
		describe "[]" do
			it do
				expect(subject['foo']).to eql('bar')
				expect(subject['lol']).to eql(['wut', 'no'])
			end
		end
	end
	context "nested document references" do
		let(:data) { {'foo' => 'bar', 'lol' => ['wut', 'no'], 'o' => {'hai' => {'rly' => ['yarly','norly']}}} }
		describe "[]" do
			it do
				expect(subject['foo']).to eql('bar')
				expect(subject['lol']).to eql(['wut', 'no'])
				expect(subject['o.hai.rly']).to eql(['yarly','norly'])
				expect(subject['o.hai.wut']).to eql([])
			end
		end
		describe "fetch" do
			it do
				expect(subject.fetch('o.hai.wut','foo')).to eql('foo')
			end
		end
		describe "has?" do
			it "should work with only a key" do
				expect(subject.has? 'foo').to eql(true)
				expect(subject.has? 'o.hai.rly').to eql(true)
				expect(subject.has? 'o.hai.rly','norly').to eql(true)
				expect(subject.has? 'o.hai.rly','gnarly').to eql(false)
				expect(subject.has? 'o.hai.wut').to eql(false)
			end
			it "should work with a value" do
			end
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dbla-0.0.7 spec/unit/document_spec.rb
dbla-0.0.6 spec/unit/document_spec.rb