Cool new thing I learned today: there's a convention to have a separate file which executes your program so you can run specs on your methods without having the program actually execute. In other words, the program should be executable via a "run" method, which is called not in the program file itself, but in another program, like so:
program.rb
def run(args)
#do some stuff
end
#helper methods
bin/program
require '../program.rb'
run(args)
This way, I can require program.rb in my specification file without the program actually running before the specs are checked. This is especially useful for programs that usually take user input.
Skills developed: Control flow, Strings, and Arrays in Ruby
QOTD: "This is one way that knot-tying is like programming. You're thinking about future you." (because you'll eventually have to untie the knot, or read your code) -Avi
No comments:
Post a Comment