From 2dfbe95aa76a03932f43be49b89033358d47b374 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Tue, 9 Jan 2024 15:59:12 -0700 Subject: [PATCH] add extra users test --- spec/acceptance/tests/users_spec.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/spec/acceptance/tests/users_spec.rb b/spec/acceptance/tests/users_spec.rb index 24aadc5..cb23c31 100644 --- a/spec/acceptance/tests/users_spec.rb +++ b/spec/acceptance/tests/users_spec.rb @@ -5,7 +5,7 @@ require_relative "../../spec_helper" describe "API call to users endpoint" do - it "returns valid data" do + it "returns valid data for all users" do uri = URI("http://localhost:8080/v1/users") response = Net::HTTP.get(uri) users = JSON.parse(response) @@ -42,4 +42,30 @@ expect(users).to eq(expected_users) end + + it "returns valid data for a single user" do + uri = URI("http://localhost:8080/v1/users/russianblue") + response = Net::HTTP.get(uri) + user = JSON.parse(response) + + expected_user = { + "uid" => "russianblue", + "uidnumber" => 20_257 + } + + expect(user).to eq(expected_user) + end + + it "returns valid data for a single user's group memberships" do + uri = URI("http://localhost:8080/v1/users/russianblue/groups") + response = Net::HTTP.get(uri) + user = JSON.parse(response) + + expected_response = [ + { "name" => "colonel-meow" }, + { "name" => "garfield" } + ] + + expect(user).to eq(expected_response) + end end