nodeinfo_controller_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe WellKnown::NodeInfoController do
  4. render_views
  5. describe 'GET #index' do
  6. it 'returns json document pointing to node info' do
  7. get :index
  8. expect(response).to have_http_status(200)
  9. expect(response.media_type).to eq 'application/json'
  10. json = body_as_json
  11. expect(json[:links]).to be_an Array
  12. expect(json[:links][0][:rel]).to eq 'http://nodeinfo.diaspora.software/ns/schema/2.0'
  13. expect(json[:links][0][:href]).to include 'nodeinfo/2.0'
  14. end
  15. end
  16. describe 'GET #show' do
  17. it 'returns json document with node info properties' do
  18. get :show
  19. expect(response).to have_http_status(200)
  20. expect(response.media_type).to eq 'application/json'
  21. json = body_as_json
  22. foo = { 'foo' => 0 }
  23. expect(foo).to_not match_json_schema('nodeinfo_2.0')
  24. expect(json).to match_json_schema('nodeinfo_2.0')
  25. expect(json[:version]).to eq '2.0'
  26. expect(json[:usage]).to be_a Hash
  27. expect(json[:software]).to be_a Hash
  28. expect(json[:protocols]).to be_an Array
  29. end
  30. end
  31. end