Skip to content

Commit

Permalink
Add correct #lookup_endpoint when building Datasets
Browse files Browse the repository at this point in the history
Fixes #48.
  • Loading branch information
Tom Johnson committed Feb 19, 2017
1 parent 6c50e05 commit a49f593
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/linked_data_fragments/builders/dataset_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def initialize(control_mapping: { 'subject' => RDF.subject },
# @return [Dataset] the dataset built from the current builder state
def build
Dataset.new(uri_root).tap do |dataset|
dataset.uri_lookup_endpoint = uri_endpoint.to_s
dataset.uri_lookup_endpoint = uri_endpoint.lookup_endpoints
dataset.search = template_builder.new(dataset, uri_endpoint).build

uri_endpoint.controls.each do |control|
Expand Down
16 changes: 13 additions & 3 deletions spec/linked_data_fragments/builders/dataset_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

it 'assigns uri endpoint' do
expect(result.uri_lookup_endpoint)
.to contain_exactly(subject.uri_endpoint.to_s)
.to contain_exactly 'http://localhost:3000/?subject='
end

it 'has the appropriate subject' do
Expand All @@ -64,8 +64,18 @@
let(:root) { 'http://example.com/my_dataset/' }
let(:template) { LinkedDataFragments::HydraTemplate.new( "#{root}{?object}") }

it 'has the paramaterized endpoint' do
expect(result.uri_lookup_endpoint).to contain_exactly template.to_s
it 'has no endpoint when none is available' do
expect(result.uri_lookup_endpoint).to be_empty
end

context 'with a subject endpoint' do
let(:template) do
LinkedDataFragments::HydraTemplate.new( "#{root}{?object,subject}")
end

it 'has the paramaterized endpoint' do
expect(result.uri_lookup_endpoint).to contain_exactly "#{root}?subject="
end
end

it 'has the paramaterized subject' do
Expand Down

0 comments on commit a49f593

Please sign in to comment.