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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -2
  3. data/Guardfile +1 -0
  4. data/HISTORY.txt +7 -0
  5. data/app/assets/stylesheets/dbd_data_engine/application.css +2 -2
  6. data/app/assets/stylesheets/dbd_data_engine/context.css +17 -0
  7. data/app/assets/stylesheets/dbd_data_engine/resource.css +13 -0
  8. data/app/controllers/dbd_data_engine/contexts_controller.rb +3 -1
  9. data/app/controllers/dbd_data_engine/resources_controller.rb +32 -12
  10. data/app/models/dbd_data_engine/context.rb +118 -7
  11. data/app/presenters/context_presenter.rb +18 -0
  12. data/app/presenters/fact_with_context.rb +14 -0
  13. data/app/presenters/resource_with_contexts.rb +14 -0
  14. data/app/views/dbd_data_engine/contexts/_context.html.haml +4 -1
  15. data/app/views/dbd_data_engine/contexts/create.html.haml +3 -1
  16. data/app/views/dbd_data_engine/contexts/index.html.haml +4 -3
  17. data/app/views/dbd_data_engine/contexts/new.html.haml +4 -3
  18. data/app/views/dbd_data_engine/data/index.html.haml +8 -2
  19. data/app/views/dbd_data_engine/resources/_fact_with_context.html.haml +4 -0
  20. data/app/views/dbd_data_engine/resources/_resource_with_contexts.html.haml +3 -0
  21. data/app/views/dbd_data_engine/resources/index.html.haml +4 -3
  22. data/app/views/dbd_data_engine/resources/new.html.haml +3 -0
  23. data/app/views/dbd_data_engine/shared/_links.html.haml +5 -0
  24. data/app/views/layouts/dbd_data_engine/application.html.haml +8 -0
  25. data/dbd_data_engine.gemspec +3 -3
  26. data/lib/dbd_data_engine/version.rb +1 -1
  27. data/spec/controllers/nothing_here_tests_in_features_and_requests +0 -0
  28. data/spec/features/contexts/index_spec.rb +9 -7
  29. data/spec/features/contexts/new_spec.rb +6 -2
  30. data/spec/features/resources/index_spec.rb +8 -7
  31. data/spec/features/resources/new_spec.rb +19 -7
  32. data/spec/models/dbd_data_engine/context/defaults_spec.rb +123 -0
  33. data/spec/models/dbd_data_engine/context/predicates_spec.rb +15 -2
  34. data/spec/presenters/context_presenter/context_summary_spec.rb +20 -0
  35. data/spec/presenters/fact_with_context/new_spec.rb +31 -0
  36. data/spec/presenters/resource_with_contexts/new_spec.rb +32 -0
  37. data/spec/requests/resources/create_spec.rb +26 -36
  38. data/spec/spec_helper.rb +3 -0
  39. data/spec/test_factories/graph.rb +34 -0
  40. data/spec/views/dbd_data_engine/contexts/_context.html.haml_spec.rb +24 -0
  41. data/spec/views/dbd_data_engine/contexts/create.html.haml_spec.rb +11 -3
  42. data/spec/views/dbd_data_engine/contexts/index.html.haml_spec.rb +6 -2
  43. data/spec/views/dbd_data_engine/contexts/new.html.haml_spec.rb +14 -6
  44. data/spec/views/dbd_data_engine/data/index.html.haml_spec.rb +10 -0
  45. data/spec/views/dbd_data_engine/resources/_fact_with_context.html.haml_spec.rb +26 -0
  46. data/spec/views/dbd_data_engine/resources/_resource_with_contexts.html.haml_spec.rb +27 -0
  47. data/spec/views/dbd_data_engine/resources/index.html.haml_spec.rb +13 -3
  48. data/spec/views/dbd_data_engine/resources/new.html.haml_spec.rb +8 -3
  49. metadata +39 -18
  50. data/app/views/dbd_data_engine/resources/_fact.html.haml +0 -3
  51. data/app/views/dbd_data_engine/resources/_resource.html.haml +0 -1
  52. data/app/views/dbd_data_engine/resources/create.html.haml +0 -9
  53. data/app/views/layouts/dbd_data_engine/application.html.erb +0 -12
  54. data/spec/views/dbd_data_engine/resources/create.html.haml_spec.rb +0 -10
@@ -0,0 +1,123 @@
1
+ require 'spec_helper'
2
+
3
+ module DbdDataEngine
4
+ describe Context do
5
+
6
+ def assert_object(context, object)
7
+ context.select{ |cf| cf.object.to_s == object }.size.should == 1
8
+ end
9
+
10
+ context 'default context does not yet exist' do
11
+
12
+ let(:current_graph) do
13
+ Dbd::Graph.new << Dbd::ContextFact.new(
14
+ subject: Dbd::ContextFact.factory.new_subject,
15
+ predicate: 'foo',
16
+ object_type: 's',
17
+ object: 'bar')
18
+ end
19
+
20
+ context 'default_from_params' do
21
+ it 'returns public_today' do
22
+ context = described_class.default_from_params('public today', current_graph)
23
+ assert_object(context, 'public')
24
+ end
25
+
26
+ it 'returns personal_today' do
27
+ context = described_class.default_from_params('personal today', current_graph)
28
+ assert_object(context, 'personal')
29
+ end
30
+
31
+ it 'returns business_today' do
32
+ context = described_class.default_from_params('business today', current_graph)
33
+ assert_object(context, 'business')
34
+ end
35
+
36
+ it 'raises for inexisting param' do
37
+ lambda{ described_class.default_from_params('foo', current_graph) }.should raise_error(/foo/)
38
+ end
39
+ end
40
+
41
+ context 'public_today' do
42
+
43
+ let(:context) { described_class.public_today }
44
+
45
+ it 'exists' do
46
+ context
47
+ end
48
+
49
+ it 'has 6 context_facts' do
50
+ context.select{ |cf| cf.class == Dbd::ContextFact }.size.should == 6
51
+ end
52
+
53
+ it 'has a public object' do
54
+ assert_object(context, 'public')
55
+ end
56
+ end
57
+
58
+ context 'personal_today' do
59
+
60
+ let(:context) { described_class.personal_today }
61
+
62
+ it "exists" do
63
+ context
64
+ end
65
+
66
+ it "has 6 context_facts" do
67
+ context.select{ |cf| cf.class == Dbd::ContextFact}.size.should == 6
68
+ end
69
+
70
+ it 'has a personal object' do
71
+ assert_object(context, 'personal')
72
+ end
73
+ end
74
+
75
+ context 'business_today' do
76
+
77
+ let(:context) { described_class.business_today }
78
+
79
+ it "exists" do
80
+ context
81
+ end
82
+
83
+ it "has 6 context_facts" do
84
+ context.select{ |cf| cf.class == Dbd::ContextFact}.size.should == 6
85
+ end
86
+
87
+ it 'has a business object' do
88
+ assert_object(context, 'business')
89
+ end
90
+ end
91
+ end
92
+
93
+ context 'default context does already exist' do
94
+
95
+ let(:public_today) { described_class.public_today }
96
+ let(:personal_today) { described_class.personal_today }
97
+ let(:business_today) { described_class.business_today }
98
+
99
+ let(:current_graph) do
100
+ Dbd::Graph.new.tap do |graph|
101
+ graph << public_today
102
+ graph << personal_today
103
+ graph << business_today
104
+ end
105
+ end
106
+
107
+ context 'default_from_params' do
108
+ it 'returns the _existing_ public_today' do
109
+ context = described_class.default_from_params('public today', current_graph)
110
+ context.subject.should == public_today.subject
111
+ end
112
+ it 'returns the _existing_ personal_today' do
113
+ context = described_class.default_from_params('personal today', current_graph)
114
+ context.subject.should == personal_today.subject
115
+ end
116
+ it 'returns the _existing_ business_today' do
117
+ context = described_class.default_from_params('business today', current_graph)
118
+ context.subject.should == business_today.subject
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module DbdDataEngine
4
4
  describe Context do
5
+
5
6
  let(:context_predicates) {
6
7
  ['context:visibility',
7
8
  'context:encryption',
@@ -10,8 +11,20 @@ module DbdDataEngine
10
11
  'dc:creator',
11
12
  'dcterms:created']}
12
13
 
14
+ let(:context_labels) {
15
+ ['Visibility',
16
+ 'Encryption',
17
+ 'License',
18
+ 'Source',
19
+ 'Creator',
20
+ 'Created']}
21
+
13
22
  it 'has all the context predicates' do
14
- described_class.predicates.should == context_predicates
23
+ described_class.predicates.map{ |p| p[:predicate] }.should == context_predicates
24
+ end
25
+
26
+ it 'has all the context labels' do
27
+ described_class.predicates.map{ |p| p[:label] }.should == context_labels
15
28
  end
16
29
  end
17
- end
30
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe ContextPresenter do
4
+ context 'context_summary' do
5
+
6
+ let(:graph) { TestFactories::Graph.full }
7
+ let(:context) { graph.to_a[0..1] }
8
+ let(:context_presenter) { described_class.new(context: context) }
9
+
10
+ it '#context_summary returns the context_summuary' do
11
+ context_presenter.context_summary.should == 'public 2013-10-13'
12
+ end
13
+
14
+ context 'raises when new is not given all arguments' do
15
+ it 'without context' do
16
+ lambda{ described_class.new({}) }.should raise_error
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe FactWithContext do
4
+ context 'klass.new with a fact and a graph' do
5
+
6
+ let(:graph) { TestFactories::Graph.full }
7
+ let(:fact_with_context) { described_class.new(fact: graph.last, graph: graph) }
8
+
9
+ it '#fact returns the fact' do
10
+ fact_with_context.fact.object.should == 'whooha'
11
+ end
12
+
13
+ it '#context_summary returns a string' do
14
+ fact_with_context.context_summary.should be_a(String)
15
+ end
16
+
17
+ it '#context_summary should be based on visibility and created date' do
18
+ fact_with_context.context_summary.should == 'public 2013-10-13'
19
+ end
20
+
21
+ context 'raises when new is not given all arguments' do
22
+ it 'without fact' do
23
+ lambda{ described_class.new(graph: graph) }.should raise_error
24
+ end
25
+
26
+ it 'without graph' do
27
+ lambda{ described_class.new(fact: graph.last) }.should raise_error
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe ResourceWithContexts do
4
+ context 'klass.new with a resource and a graph' do
5
+
6
+ let(:graph) { TestFactories::Graph.full }
7
+ let(:resource) { [graph.last] }
8
+ let(:resource_with_contexts) do
9
+ described_class.new(
10
+ resource: resource,
11
+ graph: graph)
12
+ end
13
+
14
+ it 'is enumerable' do
15
+ resource_with_contexts.map #should_not raise_error
16
+ end
17
+
18
+ it 'has FactWithContext as members' do
19
+ resource_with_contexts.first.should be_a(FactWithContext)
20
+ end
21
+
22
+ context 'raises when new is not given all arguments' do
23
+ it 'without resource' do
24
+ lambda{ described_class.new(graph: graph) }.should raise_error
25
+ end
26
+
27
+ it 'without graph' do
28
+ lambda{ described_class.new(resource: resource) }.should raise_error
29
+ end
30
+ end
31
+ end
32
+ end
@@ -15,17 +15,20 @@ module DbdDataEngine
15
15
 
16
16
  let(:one_fact) do
17
17
  {'predicate' => ['schema:givenName'],
18
- 'object' => ['Peter']}
18
+ 'object' => ['Peter'],
19
+ 'context' => 'public today'}
19
20
  end
20
21
 
21
22
  let(:two_facts) do
22
23
  {'predicate' => ['schema:givenName', 'schema:familyName'],
23
- 'object' => ['Peter', 'Vandenabeele']}
24
+ 'object' => ['Peter', 'Vandenabeele'],
25
+ 'context' => 'business today'}
24
26
  end
25
27
 
26
28
  let(:two_other_facts) do
27
29
  {'predicate' => ['schema:givenName', 'schema:familyName'],
28
- 'object' => ['Frans', 'VDA']}
30
+ 'object' => ['Frans', 'VDA'],
31
+ 'context' => 'personal today'}
29
32
  end
30
33
 
31
34
  before(:each) { DbdDataEngine.stub(:default_CSV_location).and_return(test_filename) }
@@ -35,11 +38,6 @@ module DbdDataEngine
35
38
  post(dbd_data_engine.resources_path, one_fact)
36
39
  end
37
40
 
38
- it 'calls Dbd::Resource.new' do
39
- Dbd::Resource.should_receive(:new).and_call_original
40
- post(dbd_data_engine.resources_path, one_fact)
41
- end
42
-
43
41
  before(:each) do
44
42
  Dbd::Graph.new.to_CSV_file(test_filename) # empty the file
45
43
  end
@@ -52,13 +50,12 @@ module DbdDataEngine
52
50
 
53
51
  before(:each) { post(dbd_data_engine.resources_path, one_fact) }
54
52
 
55
- it 'adds 1 line to the graph' do
56
- read_back_graph.size.should == 1
53
+ it 'adds 1 resource to the graph' do
54
+ read_back_graph.resources.size.should == 1
57
55
  end
58
56
 
59
- it 'shows the result' do
60
- expect(response.body).to include('schema:givenName')
61
- expect(response.body).to include('Peter')
57
+ it 'redirects to resources' do
58
+ expect(response).to redirect_to('/data/resources')
62
59
  end
63
60
  end
64
61
 
@@ -67,18 +64,11 @@ module DbdDataEngine
67
64
  before(:each) { post(dbd_data_engine.resources_path, two_facts) }
68
65
 
69
66
  it 'adds 2 lines to the graph' do
70
- read_back_graph.size.should == 2
67
+ read_back_graph.size.should == 8
71
68
  end
72
69
 
73
70
  it 'the 2 facts have the same subject (1 resource)' do
74
- read_back_graph.map(&:subject).uniq.size.should == 1
75
- end
76
-
77
- it 'shows the result' do
78
- expect(response.body).to include('schema:givenName')
79
- expect(response.body).to include('Peter')
80
- expect(response.body).to include('schema:familyName')
81
- expect(response.body).to include('Vandenabeele')
71
+ read_back_graph.resources.size.should == 1
82
72
  end
83
73
  end
84
74
 
@@ -90,24 +80,24 @@ module DbdDataEngine
90
80
  post(dbd_data_engine.resources_path, two_other_facts)
91
81
  end
92
82
 
93
- it 'adds 4 lines to the graph in the file' do
94
- read_back_graph.size.should == 4
83
+ it 'adds 2 resources to the graph in the file' do
84
+ read_back_graph.resources.size.should == 2
95
85
  end
86
+ end
87
+ end
88
+
89
+ context 'with a context, finds or creates and uses that context' do
90
+ context 'context did not yet exist' do
91
+
92
+ before(:each) { post(dbd_data_engine.resources_path, one_fact) }
96
93
 
97
- it 'the 4 facts are of 2 resources' do
98
- read_back_graph.map(&:subject).uniq.size.should == 2
94
+ it 'adds 1 resource to the graph' do
95
+ read_back_graph.resources.size.should == 1
99
96
  end
100
- end
101
97
 
102
- it 'shows the results for each submit' do
103
- post(dbd_data_engine.resources_path, two_facts)
104
- expect(response.body).to include('schema:givenName')
105
- expect(response.body).to include('Peter')
106
- expect(response.body).to include('schema:familyName')
107
- expect(response.body).to include('Vandenabeele')
108
- post(dbd_data_engine.resources_path, two_other_facts)
109
- expect(response.body).to include('Frans')
110
- expect(response.body).to include('VDA')
98
+ it 'adds 1 context to the graph' do
99
+ read_back_graph.contexts.size.should == 1
100
+ end
111
101
  end
112
102
  end
113
103
 
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,9 @@ require 'rspec/rails'
5
5
  # Load support files
6
6
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
7
7
 
8
+ # Load TestFactories
9
+ Dir["#{File.dirname(__FILE__)}/test_factories/*.rb"].each { |f| require f }
10
+
8
11
  RSpec.configure do |config|
9
12
  config.treat_symbols_as_metadata_keys_with_true_values = true
10
13
  config.run_all_when_everything_filtered = true
@@ -0,0 +1,34 @@
1
+ module TestFactories
2
+ module Graph
3
+ def self.factory_for
4
+ ::Dbd::Graph
5
+ end
6
+
7
+ def self.new_subject
8
+ Dbd::Fact.factory.new_subject
9
+ end
10
+
11
+ def self.full
12
+ Dbd::Graph.new.tap do |graph|
13
+ context_subject = new_subject
14
+ visibility_context_fact = Dbd::ContextFact.new(
15
+ subject: context_subject,
16
+ predicate: 'context:visibility',
17
+ object_type: 's',
18
+ object: 'public')
19
+ created_context_fact = Dbd::ContextFact.new(
20
+ subject: context_subject,
21
+ predicate: 'dcterms:created',
22
+ object_type: 's',
23
+ object: '2013-10-13')
24
+ fact = Dbd::Fact.new(
25
+ subject: new_subject,
26
+ context_subject: context_subject,
27
+ predicate: 'fact_predicate',
28
+ object_type: 's',
29
+ object: 'whooha')
30
+ graph << visibility_context_fact << created_context_fact << fact
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dbd_data_engine/contexts/_context.html.haml' do
4
+
5
+ let(:context) do
6
+ graph = TestFactories::Graph.full
7
+ context = graph.to_a[0..1]
8
+ end
9
+
10
+ before(:each) { render 'dbd_data_engine/contexts/context', context: context }
11
+
12
+ it 'shows a predicate' do
13
+ rendered.should have_css('div.context td', text: 'context:visibility')
14
+ end
15
+
16
+ it 'shows an object' do
17
+ rendered.should have_css('div.context td', text: 'public')
18
+ end
19
+
20
+ it 'shows the context_summary' do
21
+ rendered.should have_css('div.context h3', text: 'public 2013-10-13')
22
+ end
23
+ end
24
+
@@ -2,9 +2,17 @@ require 'spec_helper'
2
2
  require 'ostruct'
3
3
 
4
4
  describe 'dbd_data_engine/contexts/create.html.haml' do
5
- it 'renders' do
5
+
6
+ before(:each) do
6
7
  a = OpenStruct.new(predicate: 'foo', object: 'bar')
7
- @context = [a]
8
- render
8
+ assign(:context, [a])
9
+ end
10
+
11
+ it 'renders the links partial' do
12
+ render.should render_template('dbd_data_engine/shared/_links')
13
+ end
14
+
15
+ it 'renders the context partial' do
16
+ render.should render_template('dbd_data_engine/contexts/_context')
9
17
  end
10
18
  end
@@ -2,9 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  describe 'dbd_data_engine/contexts/index.html.haml' do
4
4
 
5
- let(:contexts) { [:foo] }
5
+ let(:stub_fact) { OpenStruct.new(predicate: 'a', object: 'b') }
6
6
 
7
- before(:each) { @contexts = contexts }
7
+ before(:each) { assign(:contexts, [[stub_fact]]) }
8
8
 
9
9
  it 'renders' do
10
10
  render
@@ -13,4 +13,8 @@ describe 'dbd_data_engine/contexts/index.html.haml' do
13
13
  it 'renders the context partial' do
14
14
  render.should render_template(partial: '_context')
15
15
  end
16
+
17
+ it 'renders the links partial' do
18
+ render.should render_template('dbd_data_engine/shared/_links')
19
+ end
16
20
  end
@@ -12,28 +12,36 @@ describe 'dbd_data_engine/contexts/new.html.haml' do
12
12
  #should_not raise_error
13
13
  end
14
14
 
15
- it 'has table header "predicate"' do
16
- rendered.should have_xpath('.//table/tr/th', :text => 'predicate')
15
+ it 'has table header "Predicate"' do
16
+ rendered.should have_css('table>tr>th', text: 'Predicate')
17
17
  end
18
18
 
19
- it 'has table header "object"' do
20
- rendered.should have_xpath('.//table/tr/th', :text => 'object')
19
+ it 'has table header "Object"' do
20
+ rendered.should have_css('table>tr>th', text: 'Object')
21
21
  end
22
22
 
23
- it 'has an array of drop down select boxes with predicates' do
23
+ it 'has an array of fields with predicates' do
24
24
  rendered.should have_field('predicate[]')
25
25
  end
26
26
 
27
+ it 'has a field with a predicate context:visibility' do
28
+ rendered.should have_field('predicate[]', with: 'context:visibility')
29
+ end
30
+
27
31
  it 'has an array of fields with objects' do
28
32
  rendered.should have_field('object[]')
29
33
  end
30
34
 
35
+ it 'has a label for Visibility' do
36
+ rendered.should have_css('table>tr>td>label', text: 'Visibility (context:visibility)')
37
+ end
38
+
31
39
  it 'has a submit button' do
32
40
  rendered.should have_button('Submit')
33
41
  end
34
42
 
35
43
  it 'has a form that posts to /data/contexts' do
36
- rendered.should have_xpath('.//form[@action="/data/contexts"][@method="post"]', :text => 'predicate')
44
+ rendered.should have_xpath('.//form[@action="/data/contexts"][@method="post"]', :text => 'Predicate')
37
45
  end
38
46
  end
39
47
  end
@@ -4,4 +4,14 @@ describe 'dbd_data_engine/data/index.html.haml' do
4
4
  it 'renders' do
5
5
  render
6
6
  end
7
+
8
+ it 'links to resources' do
9
+ render
10
+ rendered.should match(%r{<a href="/data/resources">resources</a>})
11
+ end
12
+
13
+ it 'links to contexts' do
14
+ render
15
+ rendered.should match(%r{<a href="/data/contexts">contexts</a>})
16
+ end
7
17
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dbd_data_engine/resources/_fact_with_context.html.haml' do
4
+
5
+ let(:fact_with_context) do
6
+ graph = TestFactories::Graph.full
7
+ fact = graph.last
8
+ FactWithContext.new(fact: fact, graph: graph)
9
+ end
10
+
11
+ before(:each) do
12
+ render 'dbd_data_engine/resources/fact_with_context', fact_with_context: fact_with_context
13
+ end
14
+
15
+ it 'renders the fact predicate' do
16
+ rendered.should have_css('td', text: 'fact_predicate')
17
+ end
18
+
19
+ it 'renders the fact object' do
20
+ rendered.should have_css('td', text: 'whooha')
21
+ end
22
+
23
+ it 'renders the context_summary' do
24
+ rendered.should have_css('td', text: 'public 2013-10-13')
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dbd_data_engine/resources/_resource_with_contexts.html.haml' do
4
+
5
+ let(:resource_with_contexts) do
6
+ graph = TestFactories::Graph.full
7
+ fact = graph.last
8
+ resource = [fact]
9
+ ResourceWithContexts.new(resource: resource, graph: graph)
10
+ end
11
+
12
+ before(:each) do
13
+ render 'dbd_data_engine/resources/resource_with_contexts', resource_with_contexts: resource_with_contexts
14
+ end
15
+
16
+ it 'renders the fact predicate' do
17
+ rendered.should have_css('td', text: 'fact_predicate')
18
+ end
19
+
20
+ it 'renders the fact object' do
21
+ rendered.should have_css('td', text: 'whooha')
22
+ end
23
+
24
+ it 'renders the context_summary' do
25
+ rendered.should have_css('td', text: 'public 2013-10-13')
26
+ end
27
+ end
@@ -2,15 +2,25 @@ require 'spec_helper'
2
2
 
3
3
  describe 'dbd_data_engine/resources/index.html.haml' do
4
4
 
5
- let(:resources) { [:foo] }
5
+ let(:resources_with_contexts) { [[]] }
6
6
 
7
- before(:each) { @resources = resources }
7
+ before(:each) do
8
+ assign(:resources_with_contexts, resources_with_contexts)
9
+ end
8
10
 
9
11
  it 'renders' do
10
12
  render
11
13
  end
12
14
 
13
15
  it 'renders the resource partial' do
14
- render.should render_template(partial: '_resource')
16
+ render.should render_template(partial: '_resource_with_contexts')
17
+ end
18
+
19
+ it 'renders the div class resource' do
20
+ render.should have_css('div[class=resource]')
21
+ end
22
+
23
+ it 'renders the links partial' do
24
+ render.should render_template('dbd_data_engine/shared/_links')
15
25
  end
16
26
  end
@@ -4,6 +4,7 @@ describe 'dbd_data_engine/resources/new.html.haml' do
4
4
  context 'renders' do
5
5
 
6
6
  before(:each) do
7
+ @contexts = ['a', 'b']
7
8
  @predicates = ['schema:givenName', 'schema:familyName']
8
9
  render
9
10
  end
@@ -13,17 +14,21 @@ describe 'dbd_data_engine/resources/new.html.haml' do
13
14
  end
14
15
 
15
16
  it 'has table header "predicate"' do
16
- rendered.should have_xpath('.//table/tr/th', :text => 'predicate')
17
+ rendered.should have_css('table>tr>th', text: 'predicate')
17
18
  end
18
19
 
19
20
  it 'has table header "object"' do
20
- rendered.should have_xpath('.//table/tr/th', :text => 'object')
21
+ rendered.should have_css('table>tr>th', text: 'object')
21
22
  end
22
23
 
23
24
  it 'has an array of drop down select boxes with predicates' do
24
25
  rendered.should have_select('predicate[]', options: ['schema:givenName', 'schema:familyName'])
25
26
  end
26
27
 
28
+ it 'has a select box with contexts' do
29
+ rendered.should have_select('context', options: ['a', 'b'])
30
+ end
31
+
27
32
  it 'has an array of fields with objects' do
28
33
  rendered.should have_field('object[]')
29
34
  end
@@ -33,7 +38,7 @@ describe 'dbd_data_engine/resources/new.html.haml' do
33
38
  end
34
39
 
35
40
  it 'has a form that posts to /data/resources' do
36
- rendered.should have_xpath('.//form[@action="/data/resources"][@method="post"]', :text => 'predicate')
41
+ rendered.should have_css('form[@action="/data/resources"][@method="post"]', text: 'predicate')
37
42
  end
38
43
  end
39
44
  end