... as a noob
One of the nicest thing about Jumpstart Lab's gSchool program has been the mentors.
These awesome developers have volunteered to take time out of their day to work with us on our silly projects, while we are swearing and making frustrated faces. They are saints of the highest order.
So it's no surprise that, in gratitude, a lot of us want to give back to the developer community. We want to contribute to open source... badly...
We're eager to add features to code, but it's hard to find out what features the owner(s) of a repository actually would want. And if the repo does have a wishlist, most of those things are beyond our ability to create on our own.
So how (other than hunting spelling errors) can we help?
One way I've found to contribute is with tests.
So here's my testing journey, over christmas break
I had heard about http://24pullrequests.com/ - a site which encouraged developers to make 24 pull requests before christmas. While looking around repositories, I found a lot of pull requests and todos that I wasn't sure how to tackle, but I also found some repositories that used Coveralls.io
Coveralls.io allows you to dig in and see where sections of the code are uncovered by any tests.
I found a neat little rails project called MedLink. I was able to find a model that was untested and add coverage to it.
AND THE TESTS WERE ACCEPTED - Great success.
I was now on a test fairy mission. My ego had expanded. Time to reach for larger fruits.
The second project Jekyll - they also had coveralls - but they were using Test Unit instead of RSPEC.
The Jekyll code that I targeted was commented. Even though I didn't fully understand some parts, I was able to write test scenarios that fit the comments. I did a lot of test failing and searching the entire code base for method calls to make sure I was writing tests that wouldn't be arbitrary.
This one took a lot longer - but I was pleased to submit the pull request - until OH THE TRAVIS CI BUILD FAILED
The shame! The terror! What had happened? I quickly closed the pull request and by pulled up the build
Turns out, even though it worked locally, the assert_includes method was not working out for Test Unit. I had to reformat the tests a bit to remove it, but once I did, I reopened the pull request and the build passed
AND THE TESTS WERE MERGED - I EVEN GOT HEART EMOJIS - THE JOY
The Jekyll code is pretty well covered, so I decided to tackle a harder piece of the code that I didn't understand one bit. The test was supposed to test out a successful process, or an error message rescue. After spending about two hours, I could test the happy path... but I COULD NOT compose a test situation that would bring up the rescue block.
Which was a sign that I really didn't understand it well enough to test it. So I backed off. I'll be back though, when I'm older.
Third Project: I decided to try looking in the github account repos of rubyists that I admire or know.
I found Avdi Grimm's Pair Program With Me one page website. The site is pretty simple, and didn't have a testing suite but it looked like Avdi was looking to grow the site. I decided to try and implement a new testing suite and write some capybara tests. For a multitude of reasons, it seemed unlikely that Avdi would actually merge my work (maybe he's not an rspec guy, maybe I don't know how rubby is formed, you know, etc). It did seem like a decent little challenge though at least.
But guess what. There is one little button on the page, where you put in your email and it pops up the text for a mailto button link with said email.
So to the google. I ended up using selenium, and during the googles, found an article actually written by Avdi about how critical it is to use Database Cleaner with Selenium.
I got the test to work. I submitted the pull request. THE JOY
And then the pain. One of the collaborators of the repo asked two questions, one, why poltergeist over selenium (answer: I don't know how to use that one either, and google brought me selenium first) and two, why database cleaner... because the tests don't touch the database... because there really isn't any database touching.
Oops. My noob is showing.
I did try to use poltergeist instead of selenium, but still haven't been able to figure out why it doesn't activate the mailto text correctly. The pull request has not yet been accepted, and I sort of doubt it will be.
Still - I learned how to use selenium at least. And a little humility at the end of my testing rampage.
So What Are My Next Steps?
I would definitely like to go back to Jekyll and try to add more testing. It's a neat balance to maintain adding coverage while not adding tests that are silly and therefor likely to break down the line. I'm also trying to make my pull requests small so that it's easy for a repo owner to say 'no' to any test that they consider poorly written or that doesn't actually fit with their future goals for the app. I think it's probably easy to make those mistakes as a newbie to both ruby, and the specific code base.
I had looked at contributing to GitLabHQ - and their contributing How To(manifesto) is pretty intense.
While I don't think that most repos are that selective in accepting pull requests, I would like to improve my pull requests by following their format and rules.