Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Spira.types in threads #41

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/spira.rb
Expand Up @@ -28,7 +28,7 @@ def repositories
# @see Spira::Types
# @return [Hash{Symbol => Spira::Type}]
def types
settings[:types] ||= {}
@types ||= {}
end
module_function :types

Expand Down
27 changes: 27 additions & 0 deletions spec/property_types.spec
Expand Up @@ -7,6 +7,33 @@ describe 'types for properties' do


context "when declaring type classes" do
context "in a separate thread" do
it "should be available" do
types = {}
t = Thread.new { types = Spira.types }
t.join

types.should satisfy do |ts|
ts.any? && ts == Spira.types
end
end

it "should be declared" do
lambda {
t = Thread.new do
class ::PropTypeA
include Spira::Resource
default_vocabulary RDF::URI.new('http://example.org/vocab')
base_uri RDF::URI.new('http://example.org/props')

property :test, :type => XSD.string
end
end
t.join
}.should_not raise_error TypeError
end
end

it "should raise a type error to use a type that has not been declared" do
lambda {
class ::PropTypeA
Expand Down