d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehaserequire 'spec_helper'
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehasedescribe Api::V1::LogicsController do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase let(:user) { create :user }
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase let(:logic) { create :logic, user: user }
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase context 'on GET to show' do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase context 'requesting xml representation', api_specification: true do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase before do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase # @request.env['HTTP_ACCEPT'] = 'text/xml'
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase get :show, id: logic.to_param, format: :xml
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase end
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase it { should respond_with :success }
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase it 'should respond as a application/rdf+xml' do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase expect(response.content_type).to eq('application/rdf+xml')
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase end
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase end
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase context 'requesting json representation', api_specification: true do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase let(:logic_schema) { schema_for('logic') }
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase before do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase get :show, id: logic.to_param, format: :json
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase end
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase it { should respond_with :success }
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase it 'respond with json content type' do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase expect(response.content_type.to_s).to eq('application/json')
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase end
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase it 'should return a representation that validates against the schema' do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase VCR.use_cassette 'api/json-schemata/logic' do
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase expect(response.body).to match_json_schema(logic_schema)
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase end
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase end
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase end
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehase end
d8a16b0cab9d6dca3f40f2f2f098c8a1c03d3f7bTim Reddehaseend