I don't think GetSpecialization() returns a spec ID. You want
GetInspectSpecialization(), but I think that only returns valid information after you call
NotifyInspect() and wait for an appropriate INSPECT_READY event. It's possible that it always returns good information for the "player" unit, but I'm not sure.
When does your example code that initializes playerRole execute? Specialization information is definitely not available when an addon loads, so at the very least, you will need to wait for an appropriate event (perhaps PLAYER_ENTERING_WORLD?) to fetch the specialization information.
I just recently went through this dance for
MooInspect-1.0 and
MooSpec-1.0 if you want to look at the code for those two library addons on GitHub. You could also directly use MooInspect-1.0 and use lib:QueueInspect(playerGUID) and wait on MooInspect_InspectReady toi initialize your playerRole.