api_spec.rb 612 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe '/api', type: :routing do
  4. context 'graphql' do
  5. it 'routes to the GraphqlController' do
  6. expect(post('/api/graphql')).to route_to(
  7. controller: 'api/graphql',
  8. action: 'execute',
  9. formats: :json,
  10. )
  11. end
  12. end
  13. context 'all other paths' do
  14. it 'routes to application#not_found' do
  15. path = Faker::Lorem.word
  16. expect(post("/api/#{path}")).to route_to(
  17. controller: 'api/application',
  18. action: 'not_found',
  19. formats: :json,
  20. path: path,
  21. )
  22. end
  23. end
  24. end