Write tests with Rspec for the selected code
Write comprehensive tests for the following Ruby/Rails code. Use the appropriate testing framework based on the project context:\n\n1. If it appears to be using RSpec, write RSpec tests with appropriate describe/context/it blocks, shared examples if applicable, and proper mocking/stubbing.\nFollow testing best practices including proper setup/teardown, clear expectations, and comprehensive coverage.\n\nCode to test:\n{{selection}}