dbd_data_engine 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/Guardfile +1 -0
- data/HISTORY.txt +7 -0
- data/app/assets/stylesheets/dbd_data_engine/application.css +2 -2
- data/app/assets/stylesheets/dbd_data_engine/context.css +17 -0
- data/app/assets/stylesheets/dbd_data_engine/resource.css +13 -0
- data/app/controllers/dbd_data_engine/contexts_controller.rb +3 -1
- data/app/controllers/dbd_data_engine/resources_controller.rb +32 -12
- data/app/models/dbd_data_engine/context.rb +118 -7
- data/app/presenters/context_presenter.rb +18 -0
- data/app/presenters/fact_with_context.rb +14 -0
- data/app/presenters/resource_with_contexts.rb +14 -0
- data/app/views/dbd_data_engine/contexts/_context.html.haml +4 -1
- data/app/views/dbd_data_engine/contexts/create.html.haml +3 -1
- data/app/views/dbd_data_engine/contexts/index.html.haml +4 -3
- data/app/views/dbd_data_engine/contexts/new.html.haml +4 -3
- data/app/views/dbd_data_engine/data/index.html.haml +8 -2
- data/app/views/dbd_data_engine/resources/_fact_with_context.html.haml +4 -0
- data/app/views/dbd_data_engine/resources/_resource_with_contexts.html.haml +3 -0
- data/app/views/dbd_data_engine/resources/index.html.haml +4 -3
- data/app/views/dbd_data_engine/resources/new.html.haml +3 -0
- data/app/views/dbd_data_engine/shared/_links.html.haml +5 -0
- data/app/views/layouts/dbd_data_engine/application.html.haml +8 -0
- data/dbd_data_engine.gemspec +3 -3
- data/lib/dbd_data_engine/version.rb +1 -1
- data/spec/controllers/nothing_here_tests_in_features_and_requests +0 -0
- data/spec/features/contexts/index_spec.rb +9 -7
- data/spec/features/contexts/new_spec.rb +6 -2
- data/spec/features/resources/index_spec.rb +8 -7
- data/spec/features/resources/new_spec.rb +19 -7
- data/spec/models/dbd_data_engine/context/defaults_spec.rb +123 -0
- data/spec/models/dbd_data_engine/context/predicates_spec.rb +15 -2
- data/spec/presenters/context_presenter/context_summary_spec.rb +20 -0
- data/spec/presenters/fact_with_context/new_spec.rb +31 -0
- data/spec/presenters/resource_with_contexts/new_spec.rb +32 -0
- data/spec/requests/resources/create_spec.rb +26 -36
- data/spec/spec_helper.rb +3 -0
- data/spec/test_factories/graph.rb +34 -0
- data/spec/views/dbd_data_engine/contexts/_context.html.haml_spec.rb +24 -0
- data/spec/views/dbd_data_engine/contexts/create.html.haml_spec.rb +11 -3
- data/spec/views/dbd_data_engine/contexts/index.html.haml_spec.rb +6 -2
- data/spec/views/dbd_data_engine/contexts/new.html.haml_spec.rb +14 -6
- data/spec/views/dbd_data_engine/data/index.html.haml_spec.rb +10 -0
- data/spec/views/dbd_data_engine/resources/_fact_with_context.html.haml_spec.rb +26 -0
- data/spec/views/dbd_data_engine/resources/_resource_with_contexts.html.haml_spec.rb +27 -0
- data/spec/views/dbd_data_engine/resources/index.html.haml_spec.rb +13 -3
- data/spec/views/dbd_data_engine/resources/new.html.haml_spec.rb +8 -3
- metadata +39 -18
- data/app/views/dbd_data_engine/resources/_fact.html.haml +0 -3
- data/app/views/dbd_data_engine/resources/_resource.html.haml +0 -1
- data/app/views/dbd_data_engine/resources/create.html.haml +0 -9
- data/app/views/layouts/dbd_data_engine/application.html.erb +0 -12
- data/spec/views/dbd_data_engine/resources/create.html.haml_spec.rb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 197c8d325bba5a9fe3f566a4d7ad4d120b44c5db
|
|
4
|
+
data.tar.gz: 6c17d98cb2ff05c024b000e4a8484dbad82e2cd1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34902f849a16291413b2a7d19e7143e7fa506a5d547777dcfa38795d1b91b1e7d04e2cbb6ce398c98bdb1f03ff2e9bdc1bb12e3106d18a1d871f5fa9fa782d89
|
|
7
|
+
data.tar.gz: b7b77ce9e4e58b3424e8cd0dc831a5d7c8baf5ca877a9b465465ee09a9a075519380939759a243d68fab0151b9ce2fb96e011e61b617141b0087ef646a02775f
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
|
@@ -7,6 +7,7 @@ guard 'rspec', :all_on_start => true, :all_after_pass => true do
|
|
|
7
7
|
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
|
8
8
|
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
|
9
9
|
watch(%r{^app/models/(.*)\.rb$}) { |m| "spec/models/#{m[1]}" }
|
|
10
|
+
watch(%r{^app/presenters/(.*)\.rb$}) { |m| "spec/presenters/#{m[1]}" }
|
|
10
11
|
watch(%r{^app/controllers/dbd_data_engine/(.+)_(controller)\.rb$}) do |m|
|
|
11
12
|
["spec/routing/#{m[1]}_routing_spec.rb",
|
|
12
13
|
"spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb",
|
data/HISTORY.txt
CHANGED
|
@@ -26,3 +26,10 @@
|
|
|
26
26
|
* add a naive DbdDataEngine::Context model
|
|
27
27
|
* add a naive ContextsController
|
|
28
28
|
* it takes the predicates for the "new" screen from DbdOnto::Context
|
|
29
|
+
|
|
30
|
+
0.0.6 (2013-10-25)
|
|
31
|
+
=====
|
|
32
|
+
|
|
33
|
+
* upgrade to dbd 0.1.0
|
|
34
|
+
* stylsheets
|
|
35
|
+
* default contexts ("public today" etc.)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* This is a manifest file that
|
|
2
|
+
* This is a manifest file that will be compiled into application.css, which will include all the files
|
|
3
3
|
* listed below.
|
|
4
4
|
*
|
|
5
5
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* compiled file, but it's generally better to create a new file per style scope.
|
|
10
10
|
*
|
|
11
11
|
*= require_self
|
|
12
|
-
*= require_tree
|
|
12
|
+
*= require_tree '../dbd_data_engine'
|
|
13
13
|
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.context table {
|
|
2
|
+
margin-top: 5px;
|
|
3
|
+
margin-bottom: 15px;
|
|
4
|
+
margin-left: 5px;
|
|
5
|
+
border: 1px solid darkgray;
|
|
6
|
+
color: darkblue;
|
|
7
|
+
border-collapse:collapse;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.context td {
|
|
11
|
+
padding: 3px;
|
|
12
|
+
border: 1px dotted darkgray;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.context_color{
|
|
16
|
+
color: darkblue;
|
|
17
|
+
}
|
|
@@ -5,7 +5,7 @@ module DbdDataEngine
|
|
|
5
5
|
def index
|
|
6
6
|
graph = Dbd::Graph.new
|
|
7
7
|
graph = graph.from_unsorted_CSV_file(filename)
|
|
8
|
-
@contexts = graph.
|
|
8
|
+
@contexts = graph.contexts
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def new
|
|
@@ -17,10 +17,12 @@ module DbdDataEngine
|
|
|
17
17
|
@context = Dbd::Context.new()
|
|
18
18
|
[params[:predicate], params[:object]].transpose.each do |predicate, object|
|
|
19
19
|
context_fact = Dbd::ContextFact.new(predicate: predicate,
|
|
20
|
+
object_type: 's',
|
|
20
21
|
object: object)
|
|
21
22
|
@context << context_fact
|
|
22
23
|
end
|
|
23
24
|
graph << @context
|
|
25
|
+
# TODO move this to graph
|
|
24
26
|
new_data = graph.to_CSV
|
|
25
27
|
File.open(filename, 'a') do |f|
|
|
26
28
|
f.syswrite new_data
|
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
require_dependency
|
|
1
|
+
require_dependency 'dbd_data_engine/application_controller'
|
|
2
2
|
|
|
3
3
|
module DbdDataEngine
|
|
4
4
|
class ResourcesController < ApplicationController
|
|
5
|
+
|
|
5
6
|
def index
|
|
6
|
-
|
|
7
|
-
graph = graph.from_unsorted_CSV_file(filename)
|
|
8
|
-
@resources = graph.subjects.map{ |s| graph.by_subject(s) }
|
|
7
|
+
@resources_with_contexts = resources_with_contexts(current_graph)
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
def new
|
|
11
|
+
@contexts = ['public today', 'personal today', 'business today']
|
|
12
12
|
@predicates = ['schema:givenName','schema:familyName']
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def create
|
|
16
|
-
|
|
17
|
-
@
|
|
16
|
+
# FIXME refactor to smaller function (green first, refactor next)
|
|
17
|
+
@context = Context.default_from_params(params[:context], current_graph)
|
|
18
|
+
@resource = Dbd::Resource.new(context_subject: @context.subject)
|
|
18
19
|
[params[:predicate], params[:object]].transpose.each do |predicate, object|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
@resource << Dbd::Fact.new(
|
|
21
|
+
predicate: predicate,
|
|
22
|
+
object_type: 's',
|
|
23
|
+
object: object)
|
|
22
24
|
end
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
|
|
26
|
+
# prepare the graph to append
|
|
27
|
+
append_graph = Dbd::Graph.new
|
|
28
|
+
append_graph << @context unless @context.first.time_stamp # only if not yet persisted?
|
|
29
|
+
append_graph << @resource
|
|
30
|
+
# TODO this can probably move to Dbd::Graph#append_to_file(filename)
|
|
31
|
+
append_csv = append_graph.to_CSV
|
|
25
32
|
File.open(filename, 'a') do |f|
|
|
26
|
-
f.syswrite
|
|
33
|
+
f.syswrite append_csv
|
|
27
34
|
end
|
|
35
|
+
|
|
36
|
+
redirect_to('/data/resources')
|
|
28
37
|
end
|
|
29
38
|
|
|
30
39
|
private
|
|
@@ -33,5 +42,16 @@ module DbdDataEngine
|
|
|
33
42
|
DbdDataEngine.default_CSV_location
|
|
34
43
|
end
|
|
35
44
|
|
|
45
|
+
def current_graph
|
|
46
|
+
Dbd::Graph.new.from_unsorted_CSV_file(filename)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def resources_with_contexts(graph)
|
|
50
|
+
graph.resources.map do |resource|
|
|
51
|
+
ResourceWithContexts.new(
|
|
52
|
+
resource: resource,
|
|
53
|
+
graph: graph)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
36
56
|
end
|
|
37
57
|
end
|
|
@@ -1,13 +1,124 @@
|
|
|
1
1
|
module DbdDataEngine
|
|
2
2
|
class Context
|
|
3
|
+
|
|
3
4
|
def self.predicates
|
|
4
|
-
::DbdOnto::Context.new.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
resources = ::DbdOnto::Context.new.resources
|
|
6
|
+
predicate_defining_resources = select_with_defines_predicate(resources)
|
|
7
|
+
make_predicate_label_hash(predicate_defining_resources)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.public_today
|
|
11
|
+
context_from_context_facts(public_today_context_facts)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.personal_today
|
|
15
|
+
context_from_context_facts(personal_today_context_facts)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.business_today
|
|
19
|
+
context_from_context_facts(business_today_context_facts)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.default_from_params(context_param, current_graph)
|
|
23
|
+
find_context(context_param, current_graph) || create_context(context_param)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def self.find_context(context_param, current_graph)
|
|
29
|
+
if current_graph
|
|
30
|
+
# the first occurrence is OK (no drama if multiple)
|
|
31
|
+
current_graph.contexts.detect do |context|
|
|
32
|
+
(cv = single_fact_on_predicate(context, 'context:visibility')) &&
|
|
33
|
+
cv.object == visibility(context_param) &&
|
|
34
|
+
(dc = single_fact_on_predicate(context, 'dcterms:created')) &&
|
|
35
|
+
dc.object == today.to_s
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.create_context(context_param)
|
|
41
|
+
case context_param
|
|
42
|
+
when 'public today'
|
|
43
|
+
public_today
|
|
44
|
+
when 'personal today'
|
|
45
|
+
personal_today
|
|
46
|
+
when 'business today'
|
|
47
|
+
business_today
|
|
48
|
+
else
|
|
49
|
+
raise "A valid context must be given (was given: #{context_param})"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.visibility(context_param)
|
|
54
|
+
context_param.split(/ /).first
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.today
|
|
58
|
+
Date.today
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.context_from_context_facts(context_fact_array)
|
|
62
|
+
Dbd::Context.new.tap do |context|
|
|
63
|
+
context_fact_array.each do |predicate, object_type, object| # splat
|
|
64
|
+
context << Dbd::ContextFact.new(
|
|
65
|
+
predicate: predicate,
|
|
66
|
+
object_type: object_type,
|
|
67
|
+
object: object)
|
|
10
68
|
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.public_today_context_facts
|
|
73
|
+
[['context:visibility','s','public'],
|
|
74
|
+
['context:encryption','s','clear'],
|
|
75
|
+
['context:license','s',"CC BY, Copyright #{today.year} Peter Vandenabeele"]] +
|
|
76
|
+
common_today_context_facts
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.personal_today_context_facts
|
|
80
|
+
[['context:visibility','s','personal']] +
|
|
81
|
+
encrypted_and_rights_reserved_and_common
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def self.business_today_context_facts
|
|
85
|
+
[['context:visibility','s','business']] +
|
|
86
|
+
encrypted_and_rights_reserved_and_common
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def self.encrypted_and_rights_reserved_and_common
|
|
90
|
+
[['context:encryption','s','encrypted'],
|
|
91
|
+
['context:license','s',"All rights reserved, Copyright #{today.year} Peter Vandenabeele"]] +
|
|
92
|
+
common_today_context_facts
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def self.common_today_context_facts
|
|
96
|
+
[['dc:source','s','manual by Peter Vandenabeele'],
|
|
97
|
+
['dc:creator','s','Peter Vandenabeele'],
|
|
98
|
+
['dcterms:created','s',today.to_s]]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# TODO implement some of these methods on Dbd gem to clean-up
|
|
102
|
+
|
|
103
|
+
def self.select_with_defines_predicate(resources)
|
|
104
|
+
resources.select do |resource|
|
|
105
|
+
single_fact_on_predicate(resource, 'meta:defines_predicate')
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def self.make_predicate_label_hash(resources)
|
|
110
|
+
resources.map do |resource|
|
|
111
|
+
predicate = single_fact_on_predicate(resource, 'meta:defines_predicate').object
|
|
112
|
+
label = single_fact_on_predicate(resource, 'rdfs:label').object
|
|
113
|
+
{ predicate: predicate,
|
|
114
|
+
label: label }
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def self.single_fact_on_predicate(resource, predicate)
|
|
119
|
+
resource.select do |fact|
|
|
120
|
+
fact.predicate == predicate
|
|
121
|
+
end.single
|
|
11
122
|
end
|
|
12
123
|
end
|
|
13
|
-
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class ContextPresenter
|
|
2
|
+
def initialize(options)
|
|
3
|
+
@context = options.fetch(:context)
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def context_summary
|
|
7
|
+
visibility = get_objects_for_predicate(@context, 'context:visibility')
|
|
8
|
+
created = get_objects_for_predicate(@context, 'dcterms:created')
|
|
9
|
+
"#{visibility.join(', ')} #{created.join(', ')}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def get_objects_for_predicate(context, predicate)
|
|
15
|
+
context.select{ |cf| cf.predicate == predicate }.map(&:object)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class FactWithContext
|
|
2
|
+
attr_reader :fact
|
|
3
|
+
|
|
4
|
+
def initialize(options)
|
|
5
|
+
@fact = options.fetch(:fact)
|
|
6
|
+
@graph = options.fetch(:graph)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def context_summary
|
|
10
|
+
context = @graph.by_subject(@fact.context_subject)
|
|
11
|
+
ContextPresenter.new(context: context).context_summary
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class ResourceWithContexts
|
|
2
|
+
include Enumerable
|
|
3
|
+
|
|
4
|
+
def initialize(options)
|
|
5
|
+
@resource = options.fetch(:resource)
|
|
6
|
+
@graph = options.fetch(:graph)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def each
|
|
10
|
+
@resource.each do |fact|
|
|
11
|
+
yield FactWithContext.new(fact: fact, graph: @graph)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
%h2 New context was created
|
|
2
2
|
|
|
3
|
+
=render partial: 'dbd_data_engine/shared/links'
|
|
4
|
+
|
|
3
5
|
%p content is:
|
|
4
6
|
%table
|
|
5
7
|
%tr
|
|
6
8
|
%th predicate
|
|
7
9
|
%th object
|
|
8
|
-
=render :
|
|
10
|
+
=render partial: 'context', object: @context.to_a
|
|
9
11
|
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
= form_tag('/data/contexts', method: :post) do # engine controller route not loaded in view tests
|
|
4
4
|
%table
|
|
5
5
|
%tr
|
|
6
|
-
%th
|
|
7
|
-
%th
|
|
6
|
+
%th Predicate
|
|
7
|
+
%th Object
|
|
8
8
|
- @predicates.each do |predicate|
|
|
9
9
|
%tr
|
|
10
|
-
%td=
|
|
10
|
+
%td= label_tag("#{predicate[:label]} (#{predicate[:predicate]})")
|
|
11
11
|
%td= text_field_tag('object[]')
|
|
12
|
+
%td= text_field_tag('predicate[]', predicate[:predicate], hidden: true)
|
|
12
13
|
|
|
13
14
|
%p= submit_tag('Submit')
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
%h1 Data
|
|
2
|
-
|
|
1
|
+
%h1 Data
|
|
2
|
+
|
|
3
|
+
= render partial: 'dbd_data_engine/shared/links'
|
|
4
|
+
|
|
5
|
+
%h2 See and create #{link_to('contexts','/data/contexts')}
|
|
6
|
+
%h2 See and create #{link_to('resources','/data/resources')}
|
|
7
|
+
|
|
8
|
+
|
data/dbd_data_engine.gemspec
CHANGED
|
@@ -21,10 +21,10 @@ Gem::Specification.new do |s|
|
|
|
21
21
|
s.require_paths = ['lib']
|
|
22
22
|
|
|
23
23
|
s.add_development_dependency 'rake'
|
|
24
|
-
s.add_dependency 'rails', '>= 4.0.
|
|
24
|
+
s.add_dependency 'rails', '>= 4.0.1.rc3'
|
|
25
25
|
s.add_dependency 'haml'
|
|
26
|
-
s.add_dependency 'dbd', '
|
|
27
|
-
s.add_dependency 'dbd_onto'
|
|
26
|
+
s.add_dependency 'dbd', '~> 0.1.0'
|
|
27
|
+
s.add_dependency 'dbd_onto', '~> 0.0.12'
|
|
28
28
|
|
|
29
29
|
s.add_development_dependency 'haml-rails'
|
|
30
30
|
s.add_development_dependency 'rspec-rails'
|
|
File without changes
|
|
@@ -13,11 +13,8 @@ module DbdDataEngine
|
|
|
13
13
|
::RSpec::Mocks.setup(self)
|
|
14
14
|
|
|
15
15
|
before(:each) do
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
predicate: 'foobar',
|
|
19
|
-
object: 'tuxping')
|
|
20
|
-
Dbd::Graph.any_instance.stub(:from_unsorted_CSV_file).and_return(graph)
|
|
16
|
+
Dbd::Graph.any_instance.stub(:from_unsorted_CSV_file).
|
|
17
|
+
and_return(TestFactories::Graph.full)
|
|
21
18
|
end
|
|
22
19
|
|
|
23
20
|
context 'page content' do
|
|
@@ -31,8 +28,13 @@ module DbdDataEngine
|
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
it 'shows a test context' do
|
|
34
|
-
expect(page).to have_text('
|
|
35
|
-
expect(page).to have_text('
|
|
31
|
+
expect(page).to have_text('context:visibility')
|
|
32
|
+
expect(page).to have_text('public')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'does not show Facts (only Contexts)' do
|
|
36
|
+
expect(page).to_not have_text('fact_predicate')
|
|
37
|
+
expect(page).to_not have_text('whooha')
|
|
36
38
|
end
|
|
37
39
|
end
|
|
38
40
|
end
|
|
@@ -19,11 +19,15 @@ module DbdDataEngine
|
|
|
19
19
|
expect(page.text).to match(/new context/i)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
it 'has a
|
|
22
|
+
it 'has a field array with predicates' do
|
|
23
23
|
expect(page).to have_field('predicate[]', type: 'text', count: 6)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
it 'has a field array' do
|
|
26
|
+
it 'has a field array with predicate context:visibility' do
|
|
27
|
+
expect(page).to have_field('predicate[]', type: 'text', with: 'context:visibility')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'has a field array with objects' do
|
|
27
31
|
expect(page).to have_field('object[]', count: 6)
|
|
28
32
|
end
|
|
29
33
|
end
|
|
@@ -13,11 +13,8 @@ module DbdDataEngine
|
|
|
13
13
|
::RSpec::Mocks.setup(self)
|
|
14
14
|
|
|
15
15
|
before(:each) do
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
predicate: 'foobar',
|
|
19
|
-
object: 'tuxping')
|
|
20
|
-
Dbd::Graph.any_instance.stub(:from_unsorted_CSV_file).and_return(graph)
|
|
16
|
+
Dbd::Graph.any_instance.stub(:from_unsorted_CSV_file).
|
|
17
|
+
and_return(TestFactories::Graph.full)
|
|
21
18
|
end
|
|
22
19
|
|
|
23
20
|
context 'page content' do
|
|
@@ -30,9 +27,13 @@ module DbdDataEngine
|
|
|
30
27
|
expect(page).to have_text('Resources')
|
|
31
28
|
end
|
|
32
29
|
|
|
30
|
+
it 'does not show Contexts (only Facts)' do
|
|
31
|
+
expect(page).to_not have_text('context:visibility')
|
|
32
|
+
end
|
|
33
|
+
|
|
33
34
|
it 'shows a test resource' do
|
|
34
|
-
expect(page).to have_text('
|
|
35
|
-
expect(page).to have_text('
|
|
35
|
+
expect(page).to have_text('fact_predicate')
|
|
36
|
+
expect(page).to have_text('whooha')
|
|
36
37
|
end
|
|
37
38
|
end
|
|
38
39
|
end
|
|
@@ -15,16 +15,28 @@ module DbdDataEngine
|
|
|
15
15
|
visit(dbd_data_engine.new_resource_path)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
context 'resource' do
|
|
19
|
+
it 'talks about a new resource' do
|
|
20
|
+
expect(page).to have_css('h1', text: 'Create a new resource')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'has a select box array with schema:givenName as option' do
|
|
24
|
+
expect(page).to have_select('predicate[]', options: ['schema:givenName','schema:familyName'])
|
|
25
|
+
end
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
it 'has a field array' do
|
|
28
|
+
expect(page).to have_field('object[]')
|
|
29
|
+
end
|
|
24
30
|
end
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
context 'select a context' do
|
|
33
|
+
it 'has a label "context"' do
|
|
34
|
+
expect(page).to have_css('label', text: 'Context')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'has a select box for the context' do
|
|
38
|
+
expect(page).to have_select('context', [])
|
|
39
|
+
end
|
|
28
40
|
end
|
|
29
41
|
end
|
|
30
42
|
end
|