# frozen_string_literal: true require "rails_helper" RSpec.describe "Api::V1::Sports", type: :request do let!(:user) { User.create!(email: "s@example.com", password: "secret123", name: "U", role: "coach") } it "GET /api/v1/sports restituisce il catalogo" do post "/api/v1/auth/login", params: { email: user.email, password: "secret123" } token = response.parsed_body["access_token"] get "/api/v1/sports", headers: { "Authorization" => "Bearer #{token}" } expect(response).to have_http_status(:ok) body = JSON.parse(response.body) expect(body).to be_an(Array) pallavolo = body.find { |s| s["key"] == "pallavolo" } expect(pallavolo["board"]).to eq("volley") expect(pallavolo["allowed_overlays"]).to include("volley", "none") expect(pallavolo["allowed_overlays"]).not_to include("timer") end end