= create(:user) end describe "GET 'index'" do it "returns http success when authenticated with a token" do get :index expect(response).to be_success end it "returns 401 unauthorized when not authenticated with a token" do @request.headers["Authorization"] = nil get :index expect(response.status).to eq(401) end it "returns 401 unauthorized when not authenticated as an admin" do inject_token(@user) get :index expect(response.status).to eq(401) end it "returns all of the things" do create_list(:thing, 5) get :index expect(json_response.length).to eq(5) end end end