Using Standard In and Out In Ruby Code

My mentor, Kim Barnes, knocked it completely out of the park helping with my first question!

I sent her a very silly command line game that I've been working on.

My main questions was how can you test a game that has a lot of requests for input from the user?  

She took the time to generate the following examples:

A simple, hard to test engine

A simple, easy to test engine 

The test that matches the simple, easy to test engine

She also sent me a link an the article to better understand what was going on

I had asked her if it was common to have a lot of 'gets.chomp' style code in normal ruby programs, or if this was just something I had a lot of while I'm learning on simple command line games. Her response was gold!

Using gets/puts in production code is not that common, but could be useful for command line scripts.  But I think in general, the idea you're getting of making the code easy to test is the important part, and knowing how to stub gets/puts is just a detail you can research again later if you ever need it.

Minitest :: How. What? Who. How?

I am Sadly. Pathetically. Sort of. Testing. 

Right now I'm using Minitest to test my ruby projects. I'm really getting bogged down in not knowing the assertion commands. So I can test if things are equal. And that's about it.

My solution is to try and create a decent flashcard set

Here are the flashcards

I pulled a lot of the examples from Matt Sears Blog and of course, the documentation.

I am also trying to 'TDD' a silly game for ex45 of Learning Ruby the Hard Way

Here is a link to the github repository as I work

Unfortunately, I've made two major errors so far

1. I started pushing to the master branch instead of breaking off into work branches. Currently my little project doesn't work. 

2. I didn't do enough research on how to test puts statements - so making my game functional makes all the tests fail


So next steps? 

  1. I'm going to read over the examples in the Matt Sears blog again and try to understand exactly what he's testing.
  2. Read over the documentation and compare it to what I have in the flashcards to make sure I'm understanding things correctly.
  3. Go back to my little project and attempt to get all broken tests working.



  1. I'm mainly concerned that minitest won't be a tool that I use very often after this. I should probably read more tutorials and screen casts to get a better idea of its ultimate use, and if I should switch focusing on RSPEC instead.

First Project of GSchool :: Event Reporter :: A Retrospective

It seems odd to quantify this as a retrospective when I am not, actually technically done with the project.  

  • So here was the assignment:
  • And here was my initial attempt: 
  • And here was the complete restart:

To summarize - this was the first project that we were asked to take on without specific direction - ie a tutorial to follow along with. We were given direction by way of being told what the app should do but not how  it should do it. We were also given a list of test contents that should pass.

I'm still very much struggling with working with other people, so my initial approach was just to put my head down and barrel through on my own. While we were assigned partners to work with, we were expected to write our own projects and turn them in separately. When I say struggling to work with other people, I should clarify that this is not because I think I'm smarter or that much dumber than anyone else in the class, or that anyone in the class is less that totally onboard to work together... I just have an incredibly difficult time expressing myself when co-working... Also, I'm shy. 

So my first step in trying to understand the assignment was to write out dummy tests in order to figure out what was being asked and get a 'whole picture'. 

This helped me get a 'big picture' - but I never used the tests. 

I then just started barreling. 

Things I Learned

Watch your classmate's tutorial videos:

Test. - I tried to use Minitest... failed after the third test on my first attempt, got a little further on the second. I tested with puts statements and working through the assignment... but there was no safeguard and I had to store everything in my head. I'm still having trouble pushing the application to 'production' because I can't manually test very quickly while I'm connecting all the commands. 

'puts' at the end of a method returns nil. Useful for guess, run program and then check. Exceptionally not useful for trying to pass tests

Things I Didn't Learn(but want to learn)

I got closer, but I still can't test very well. I got stuck on the tests not reading the csv file. It killed my testing. 

I still don't understand how to split my mega application into separate files. It is a mysterious mystery.

How to pair program.  

In Conclusion

It was fine for the first project, cause I was on a 'forest is on fire' style of learning whatever I could access... but next time I need to focus less on 'getting shit done' and more on taking the time to test, work with others and be okay with the application not being complete. 

The application isn't complete anyway.  

That said, I had a hell of a time and can't wait to clean up ol' Event Reporter Redux