'How can I detect the timing when I have to change a method in rspec?
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?
Solution 1:[1]
C has no standard types specified to support numbers of 20 decimal digits (has you ask about in the title) or 50 digits (as you mention later) or 100,000 digits (as numbers up to 10100,000 require).
You can read user input as sequences of characters, and you can write code to change those codes into digits and to manipulate sequences of digits as decimal numerals as we were all taught in elementary school. You can also use third-party packages such as GMP to work with large numbers.
If you are working on some online-judge or other challenge problem that apparently involves numbers up to 10100,000, then you should be aware that such problems often have, by design, alternate methods of computing their required results that do not require use of large numbers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eric Postpischil |
