testing helpers in rails 2.0

I’ve been testing helper classes in rails using the method from the Rails Recipes book. That seems to be broken in rails 2.0 since @params and @request are no longer accessible in controllers. Luckily I also use mocha for mocks and stubs, so this was a quick fix.

So, the new code for testing rails helpers is (for me anyway):

require File.dirname(__FILE__) + '/../test_helper'

class ApplicationHelperTest < Test::Unit::TestCase
  include ActionView::Helpers::UrlHelper
  include ActionView::Helpers::TextHelper
  include ActionView::Helpers::TagHelper
  include ApplicationHelper

  def setup
    @controller = HomeController.new
    request = ActionController::TestRequest.new
    @controller.expects(:params).returns(Hash.new)
    @controller.expects(:request).returns(request)
    @controller.send(:initialize_current_url)
  end

  ...tests...
end

fb2twit: facebook to twitter status updates

I wrote a Facebook application called fb2twit to send Facebook status updates to Twitter. The official twitter app and others only seem to go the other way (Twitter to Facebook). However, I find people who update their statuses on Facebook all the time mildly annoying. However, that is expected on Twitter. With this app you can update Facebook a couple of times a day while updating Twitter to your heart’s content.

So if you use both Facebook and Twitter, install fb2twit and let me know what you think!

amazon s3 outage this morning

We moved SnapMyLife over to amazon ec2 and s3 hosting because we figured they’re amazon, so hey what are the odds of them going down? According to their SLA they claim a “3 nines” (99.9%) uptime per month. This actually means they’re allowed .75 hours of downtime every month. They were down for 4 hours today (so far).

I understand that things happen, and it wasn’t so much the outage that pissed everyone off, it was the response. They didn’t post anything on the AWS website, you had to dig around the forums. Then, the only responses were “we’re looking into it” and “it’s been resolved”. No ETA’s ever.

I’m sure Amazon just lost some customers today, although we’re not one of them. I just wish they’d have better communication on their end so we could relay to our customers.

mms2r and scRUBYt

One thing I never enjoyed doing as a developer is writing crawlers, parsers, and scrapers. They always seem flaky and by definition the node tree can change without warning. Luckily, there are developers out there that really love hacking at this stuff… and that makes all of our lives easier.

The first project I use all the time is scRUBYt which is primarily maintained by Peter. He is always willing to help out and we’ve contracted his work a few times at Mobicious. scRUBYt is like Hpricot on steroids. It is trying to prevent the flakiness of your scripts along with trying to get you out of the XPath game. It works great for almost all dynamic websites. More importantly, when the site changes markup it is easy to re-run your learning scripts and update your crawlers.

The other project that I’m loving more and more is mms2r. It is a ruby library that processes picture and video messages from mobile phones. We use it extensively for SnapMyLife. I tell you sites like ours would be a bear to code without the grunt work of developers like Matt Mondragon. Mms2r a well thought out project that only requires you to add extra carrier templates if they do something odd. He’s even helped me out with some fixes to templates I couldn’t seem to get right myself.

Bottom line, it’s the people behind the software that make it so enjoyable. Most small open source projects really are a team of one. Show them some support. You don’t need to fix bugs (although that is appreciated), just give them feedback and try and help. Hell, write some documentation… every developer hates writing it and it is hard to know what the user needs help with.