Suppose I have the following code.
class Answer
enum type: %i[text checkbox image]
def round_type
case answer.type
when text, checkbox
:text
when image
:multimedia
else
raise 'Unknown type'
end
end
end
require 'rails_helper'
RSpec.describe Answer, type: :model do
describe '#round_type' do
context 'when type is text' do
it 'returns text' do
# omitted
end
end
context 'when type is checkbox' do
it 'returns text' do
end
end
context 'when type is image' do
it 'returns multimedia' do
end
end
end
end
Then I add video type to the enum. And I expect the method returns multimedia when the type is video.
But the round_type method and the test codes are not support video type. So I will finally realize it when I get an error in production.
I'd like to know what I have to change the method before the error occurs.
So, this is my question: How can I detect the timing when I have to change a method in rspec?