Skip to content

Commit

Permalink
Merge pull request #292 from samvera/response_media_type
Browse files Browse the repository at this point in the history
use response.media_type instead of .content_type in tests
  • Loading branch information
elrayle authored Nov 22, 2019
2 parents 639003c + 769d86f commit 7f8ccc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions spec/controllers/linked_data_terms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,22 +403,22 @@
it 'succeeds and defaults to json content type' do
get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/json'
expect(response.media_type).to eq 'application/json'
end

context 'and it was requested as json' do
it 'succeeds and returns term data as json content type' do
get :show, params: { id: '530369', vocab: 'OCLC_FAST', format: 'json' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/json'
expect(response.media_type).to eq 'application/json'
end
end

context 'and it was requested as jsonld' do
it 'succeeds and returns term data as jsonld content type' do
get :show, params: { id: '530369', vocab: 'OCLC_FAST', format: 'jsonld' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/ld+json'
expect(response.media_type).to eq 'application/ld+json'
expect(JSON.parse(response.body).keys).to match_array ["@context", "@graph"]
end
end
Expand All @@ -427,7 +427,7 @@
it 'succeeds and returns term data as n3 content type' do
get :show, params: { id: '530369', vocab: 'OCLC_FAST', format: 'n3' }
expect(response).to be_successful
expect(response.content_type).to eq 'text/n3'
expect(response.media_type).to eq 'text/n3'
expect(response.body).to start_with "@prefix"
end
end
Expand All @@ -436,7 +436,7 @@
it 'succeeds and returns term data as ntriples content type' do
get :show, params: { id: '530369', vocab: 'OCLC_FAST', format: 'ntriples' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/n-triples'
expect(response.media_type).to eq 'application/n-triples'
expect(response.body).to include('<http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell University"')
end
end
Expand Down Expand Up @@ -476,7 +476,7 @@
it 'succeeds and defaults to json content type' do
get :show, params: { id: 'sh 85118553', vocab: 'LOC', subauthority: 'subjects' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/json'
expect(response.media_type).to eq 'application/json'
end
end
end
Expand Down Expand Up @@ -578,22 +578,22 @@
it 'succeeds and defaults to json content type' do
get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/json'
expect(response.media_type).to eq 'application/json'
end

context 'and it was requested as json' do
it 'succeeds and returns term data as json content type' do
get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG', format: 'json' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/json'
expect(response.media_type).to eq 'application/json'
end
end

context 'and it was requested as jsonld' do
it 'succeeds and returns term data as jsonld content type' do
get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG', format: 'jsonld' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/ld+json'
expect(response.media_type).to eq 'application/ld+json'
expect(JSON.parse(response.body).keys).to match_array ["@context", "@graph"]
end
end
Expand All @@ -602,7 +602,7 @@
it 'succeeds and returns term data as n3 content type' do
get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG', format: 'n3' }
expect(response).to be_successful
expect(response.content_type).to eq 'text/n3'
expect(response.media_type).to eq 'text/n3'
expect(response.body).to start_with "@prefix"
end
end
Expand All @@ -611,7 +611,7 @@
it 'succeeds and returns term data as ntriples content type' do
get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG', format: 'ntriples' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/n-triples'
expect(response.media_type).to eq 'application/n-triples'
expect(response.body).to include('<http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell University"')
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/terms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def search(_arg1, _arg2)
it 'Access-Control-Allow-Origin is not present' do
get :show, params: { vocab: "discogs", subauthority: "release", id: "3380671", format: 'n3' }
expect(response).to be_successful
expect(response.content_type).to eq 'text/n3'
expect(response.media_type).to eq 'text/n3'
expect(response.body).to start_with "@prefix"
end
end
Expand All @@ -248,7 +248,7 @@ def search(_arg1, _arg2)
it 'Access-Control-Allow-Origin is not present' do
get :show, params: { vocab: "discogs", subauthority: "release", id: "3380671", format: 'ntriples' }
expect(response).to be_successful
expect(response.content_type).to eq 'application/n-triples'
expect(response.media_type).to eq 'application/n-triples'
expect(response.body).to include('_:agentn1 <http://www.w3.org/2000/01/rdf-schema#label> "Dexter Gordon"')
end
end
Expand Down

0 comments on commit 7f8ccc4

Please sign in to comment.