Gist 850654
This example shows how to test authorization and role-protected attribute updates in a Rails controller using RSpec. It verifies that a user cannot edit another user’s profile, can change their own given name, and cannot modify their role field, with assertions on flash messages, response codes, and assigned attributes. The code uses Devise::TestHelpers to sign in a factory-built user, and RSpec’s `describe`, `context`, and `it` blocks to structure the test cases.