self.extended(thoughts)

Code, Entrepreneurship, Music, Life

Review of Udmey Course: BDD and TDD in Ruby by Roy Osherove

Avdi Grimm recently tweeted about a new Udmey course TDD and BDD in Ruby by Roy Osherove. I’m not sure if this was an endorsement by Avdi, or more of a “oh hey, there’s this thing over here which might be interesting” type mention, but when Avdi tweets… people listen, so I decided to go check out the course. What follows is the review I left on the Udmey site, shared here more widely.

As an experienced developer, I’d give this course 3.5 stars if it was an option, but I rounded up because if you don’t know anything about unit testing then this course is a great overview.

The most valuable parts to me were the advanced RSpec overview and discussion of fakes (mocks, stubs). Roy covers this well, but encourages using a 3rd party mock library outside of what RSpec provides called Bogus. The reason is to allow for non-strict mock expectations, which are less brittle since they don’t complain every time a method on the object under test is called that you didn’t explicitly stub out. However, RSpec does support this with the as_null_object method so it would have been nice to not introduce an additional gem unnecessarily.

How to Be a One-Man Coding Army for a Startup

Last weekend I was fortunate enough to be invited to speak at Chippewa Valley Code Camp - 2012. CVCC is a free, 1-day, 4-track conference in Eau Claire, WI that attracts some of the brightest developers in Wisconsin and Minnesota.

This year there were over 120 attendees and some 20 speakers presenting on things ranging from running a massive Java web application at scale to Single Page Applications with JavaScript. I had an awesome time meeting new people and sharing a little bit about how I run the technical and development side of Bolstr. Specifically, I talked about how we collaborate on work-flows for new features through user stories with Cucumber as we build out our Ruby on Rails web application at Bolstr.com.

The slides from my talk “How to be a One-Man Coding Army for a Startup” are available online, and if you attended the session I’d sure love it if you could leave some feedback at speakerrate for me.

Also, a big shout out to Brian Hogan for encouraging me to submit a talk and even suggesting the name. Thanks Brian!

Using PhantomJS (Through Poltergeist) and Selenium in the Same Cucumber Test Suite

We use DocuSign at Bosltr to facilitate electronic signatures and testing this functionality with Cucumber has proved to be quite a pain. First of all DocuSign uses an iframe to deliver its functionality so there was that added complexity right off the bat. Secondly, because we’re doing integration testing, I wanted to actually hit the DocuSign test servers and verify that things are still working as I expect. Stubbing the requests out wouldn’t give me insight into any unexpected API changes breaking our app. Because we’re reaching out externally I had to account for the delay in receiving data from DocuSign often needing to revert to ugly things like sleep 3 in the step definitions.

The default Selenium driver through Firefox is the only solution for testing the DocuSign iframe that I could get working. However, the rest of the test suite that needs JavaScript testing has been working wonderfully on Poltergeist, an awesome headless PhantomJS driver for Capybara. Poltergeist was throwing errors about elements overlapping in the DocuSign iframe that I couldn’t solve but I didn’t want to abandon Poltergeist and revert to Selenium for ALL our JS testing, so I figured out a way to use both by tagging stories and using some Before and After hooks.

Wiring Up LittleSnapper to CloudApp

I used to love Skitch, but the recent changes have made it less awesome so I decided to seek out alternative options. I have a licensed copy of LittleSnapper from a bundle of Mac apps that I purchased a while back so I decided to give it a go.

I also use CloudApp multiple times per day (and pay for a pro subscription) so I was encouraged when I saw an article stating that RealMac (the team behind LittleSnapper) was working on integration with CloudApp, but nothing has developed on that front in over a year and I didn’t want to wait any longer so I started down the path of solving the problem myself.

Here’s how it works:

  • Configure LittleSnapper to use SFTP to “publish” locally to a folder of your choosing.
  • Create a new Automator “Folder Action” which runs an AppleScript when the contents of the folder changes.
  • Use the CloudApp API through a Ruby script (called by the aforementioned AppleScript) to publish the given file.

Breaking Out of an Iframe From a Rails Controller

For the docusign_rest gem that I recently created I needed to break out of the DocuSign iframe after a signer successfully signed the embedded PDF and redirect to a controller action showing that action’s view.

After a bit of Googling I found this code snippet:

1
2
3
4
5
6
7
<html>
  <body>
    <script type='text/javascript' charset='utf-8'>
      parent.location.href = '/myloc';
    </script>
  </body>
</html>

Which can be implemented in a Rails controller like so:

1
render text: "<html><body><script type='text/javascript' charset='utf-8'>window.parent.document.location.href = '/myloc';</script></body></html>", content_type: :html