You want to write the code that you had. In C / style languages, statically compiled languages ββdid not even compile the above, since you correctly pointed out that the code does not exist. This is normal, then you should implement a minimum minimum in order to build code in order to run your tests. In other words, your tests drive your design.
My Ruby is very rusty, but in the above example, something along the lines of method_missing
will be selected for methods / properties that do not exist. Therefore, you would create them.
class Person attr_accessor :firstname, :lastname def fullname end end
If you run your test, you will get zero returned from the full name. Therefore, we will use the fullname method. It should be noted here that the message changed, and does not run, when he groaned about the missing methods, the test groaned, that we did not implement the methods correctly.
def fullname return @firstname + " " + @lastname end
Now your test will pass.
Basically, you want to either change the message that your test shows after running (it turns out that you are getting somewhere), or you want to skip it. After passing the test, you can reorganize. The above method is simple, but you can opt out of the return statement, use string formatting, or whatever. As long as the test passes, you know that you are good to go.
source share