Skip to content

Instantly share code, notes, and snippets.

View elrayle's full-sized avatar

E. Lynette Rayle elrayle

View GitHub Profile
@elrayle
elrayle / gist:11a75d47f8cb9b1932e5
Created September 9, 2014 15:23
Set of RSpec tests for an ActiveTriples property that holds multiple URI values
describe 'aggregates' do
it "should be empty array if we haven't set it" do
expect(subject.aggregates).to match_array([])
end
it "should be set to a URI producing an ActiveTriple::Resource" do
subject.aggregates = RDF::URI("http://example.org/b1")
expect(subject.aggregates.first).to be_a ActiveTriples::Resource
end
@elrayle
elrayle / gist:50d14ba381553107e618
Created September 12, 2014 19:07
ActiveTriples: Test for set_value deletes all values
describe "set_value" do
it "should add a single value when none exist a priori" do
vals = subject.get_values('aggregates')
vals << "foo"
subject.set_value('aggregates',vals)
expect(subject.get_values('aggregates')).to eq ["foo"]
end
it "should add a single value when one value exists a priority" do
subject.aggregates = "foo"
@elrayle
elrayle / gist:f5f559f8c10243600dc6
Last active August 29, 2015 14:09
Ruby array limit testing using List Item Info datastructure as each item in the array
class Array
def move(from,to)
insert(to, delete_at(from))
end
end
def gen_list(max_items)
items = []
header_info = {}
@elrayle
elrayle / gist:647bd8f3fda3baa9ddd2
Last active August 29, 2015 14:10
new - persist! - destroy - persisted? shows resource as persisted
require 'spec_helper'
describe ActiveTriples::Resource do
describe '#destroy' do
before do
class DummyResource < ActiveTriples::Resource
configure :type => RDF::URI('http://example.org/SomeClass'),
:base_uri => 'http://example.org/dummy/',
:repository => :default
@elrayle
elrayle / gist:f9eda7cc99015ef1ab6b
Created May 13, 2015 16:58
Appending an rdf type to a pcdm file
t = file.metadata_node.get_values(:type)
t << RDFVocabularies::WorksTerms.Thumbnail
file.metadata_node.set_value(:type,t)
@elrayle
elrayle / gist:409e4a773e49d9a15b12
Last active August 29, 2015 14:23
implementation of pcdm:order
module Hydra::PCDM
class Order < ActiveFedora::Base
include Hydra::PCDM::OrderBehavior
end
end
module Hydra::PCDM
module OrderBehavior
extend ActiveSupport::Concern
# MODIFICATIONS to object code
module Hydra::PCDM
class ObjectBehavior
# pcdm:hasMember objects
aggregates :members, predicate: RDFVocabularies::PCDMTerms.hasMember,
class_name: "ActiveFedora::Base"
# ore:aggregates related objects
indirectly_contains :related_objects, has_member_relation: RDF::Vocab::ORE.aggregates,
inserted_content_relation: RDF::Vocab::ORE.proxyFor, class_name: "ActiveFedora::Base",
@elrayle
elrayle / gist:310949b60e592c483441
Last active August 29, 2015 14:24
pcdm/models/object_spec.rb with << tests included
require 'spec_helper'
describe Hydra::PCDM::Object do
describe '#objects=, +=, <<' do
context 'with acceptable child objects' do
let(:object1) { described_class.new }
let(:object2) { described_class.new }
let(:object3) { described_class.new }
let(:object4) { described_class.new }
@elrayle
elrayle / gist:6a60dd51a0f068229fc6
Created July 16, 2015 18:41
activefedora-aggregation #delete and testing
describe "delete fails" do
before do
image.child_objects = [test_object]
expect( image.child_objects ).to eq [test_object] # FAILS when using this line
image.child_objects.delete(test_object)
end
subject { image.child_objects }
it { is_expected.to eq [] }
@elrayle
elrayle / gist:129ecac092587b8d9849
Created September 2, 2015 19:43
my first capybara test
require 'spec_helper'
describe 'generic_files/new.html.erb', type: :view do
let(:user_collection) {
default_option = SolrDocument.new(id: -1, title_tesim: "Select collection...")
col1 = SolrDocument.new(id: "1", title_tesim: "col1")
col2 = SolrDocument.new(id: "2", title_tesim: "col2")
[default_option, col1, col2]
}