David Goudreau's blog



David GoudreauDavid Goudreau
Make the RubyMine 2.0.1 debugger work for you...
edit Posted by David Goudreau on Wednesday February 17, 2010 at 04:02PM

In the latest Rubymine 2.0.1, we've had lots of problems on our workstations with getting it working reliably. Seeing as how I love using a debugger and look forward to leaving the days of puts behind, I've spent a fair amount of time troubleshooting this problem.

Here's the deal - Rubymine 2.0.1 must have ruby-debug-ide -v=0.4.7 installed to work correctly, not the latest, which is ruby-debug-ide -v=0.4.9. You should also check out the Console tab of the debugger if you need any additional troubleshooting help.

So go ahead, uninstall 0.4.9, install 0.4.7 open up Rubymine 2.0.1 and start debugging - your inner troubleshooter will thank you.

David GoudreauDavid Goudreau
Standup 12/04/2009
edit Posted by David Goudreau on Friday December 04, 2009 at 09:33AM

Help!

David GoudreauDavid Goudreau
Standup 12/03/2009
edit Posted by David Goudreau on Thursday December 03, 2009 at 09:31AM

Help!

  • Git branch best practices - we have a customer who doesn't do acceptance often enough so we'd like to keep production code in a different branch from demo code. Any suggestions?

    Our friend Josh Susser has a good blog post on git branching workflow. Some other suggestions are to have a separate 'deploy' branch which you cherrypick changes from your 'development' branch with and deploy to production with (this would, however, require a separate integration test process to integrate the cherrypicked changes). Or, of course, round up your customer and have them do acceptance more regularly.

  • RubyMine - some Pivots are having issues running RSpec in their Rails projects.

    The usual steps we take are to make sure you can Command-click the rspec and spec/rails references in your spec_helper.rb and get to the gems they correspond to and to make sure your spec directory is flagged as a test directory in Settings => Project Structure in RubyMine. That didn't seem to solve this particular issue, though. There was some talk about commenting out arbitrary 'require' statements in your files and that change somehow making RSpec run correctly. Strange.

  • Testing paperclip - tests don't behave correctly when running them in RubyMine. There are issues with the 'identify' command.

    A possible issue is that ghostscript is not installed. Paperclip uses ImageMagick which uses ghostscript to identify attachment file types. You can install ghostscript using MacPorts. This can be tough to track down because paperclip appears to just swallow the exception that occurs when using ghostscript. Some other projects are mocking out paperclip in their tests to avoid the issue completely.

  • validates_associated fun in 2.3.5 - it's changed from 2.3.4. Another change is depending on rack 1.0.1

  • You can now boot from ebs on Amazon

  • It appears that ActiveRecord now validates all associated objects by default, for any type of validation. Given this example:

    class User < AR::Base
      has_many :wibbles
    end
    
    
    class Wibble < AR::Base
      validates_presence_of :name
    end
    

    when you save a User, it will validate all associated wibbles and fail validation if any wibble fails validation. This always happens on create, and it appears happens on update if the association is an auto-save association, which it implicitly becomes if you allow nested attribute create/update for the association.

    Before Rails 2.3.4 a failed validation on an association would give you a moderately nonsensical validation error. In the case of the above example, if the name validation failed on an associated wibble then the user would have the error "Name can't be blank," which is, of course, misleading. The attribute name for the error would just be "name", so tests for the validation would be something like @user.should have(1).error_on(:name)

    As of Rails 2.3.4 (possibly 2.3.3) the error message for a validation failure on an associated object changed to include the object type, so if the name validation failed on an associated wibble then the user would have the error "Wibbles name can't be blank." They accomplished this by changing the attribute name for the error to "#{association_name}_#{attribute_name}", thus "wibbles_name". Tests for the validation would have to change to @user.should have(1).error_on(:wibbles_name)

    As of Rails 2.3.5, the error message for a validation failure on an associated object is back to what it was pre-2.3.4 ("Name can't be blank"). However, this is because the attribute name for the error is now "#{association_name}.#{attribute_name}. So, tests have to change again to @user.should have(1).error_on('wibbles.name')

    Not really a huge difference, just an annoyance that it keeps changing.

Interesting Things

  • SMSW - this is an annual supermarket street sweep that benefits the San Francisco Food Bank. Ride on bikes, pick up foodstuffs from supermarkets and win prizes while helping the Food Bank! This Saturday 12/5 at noon.

  • Check out the AAU Future Tense exhibit at 688 Sutter Street Gallery - a showing of art that you can actually pick up with your hands! Exhibit is open thru January.

David GoudreauDavid Goudreau
Standup 12/01/2009
edit Posted by David Goudreau on Tuesday December 01, 2009 at 10:14AM

Help!

  • Heroku logs - how do you get more than 20 lines? Is there an option to get the entire log? Apparently there used to be an option to get the whole thing. Looks like we're not the only ones looking for this.
  • Webrat - is it really as incomplete as it appears? The answer is yes. We've had to create a bunch of the api ourselves to facilitate using it. If you know you're just going to use the Selenium portion of it without the Rails integration option then you might just call the Selenium API directly (which Webrat does make available to you) from your Selenium tests.

Interesting Things

  • Rails XML parameter rudeness - sometimes when only a single model is posted, it does not generate the second array, and instead gives you a hash (i.re. not wrapped in []). This is apparently a well-known bug. Workaround is pretty straightforward:

    widgets = params[:widgets][:widget]
    if widgets.is_a?(Hash)
      widgets = [widgets]
    end
    
  • Movember is over but you can revel in the 'stashes all year long at Pivotal Movember.

In my previous article I talked about using environment.plist to set environment variables in RubyMine. Well, it turns out that environment.plist doesn't always work. Specifically, if you start RubyMine from Spotlight RubyMine has a different parent process that DOESN'T take into account the environment.plist file. It DOES work if you open RubyMine using the Dock or Quicksilver, though. Who would have guessed? This easily killed a day or so of troubleshooting on my current project. So, to really solve this problem, it turns out you have to put your environment variables in /etc/launchd.conf like this:

setenv M2_HOME /opt/maven/2.0.9

For more details, check out this blog post and this blog post.

David GoudreauDavid Goudreau
Setting environment variables in RubyMine on a Mac
edit Posted by David Goudreau on Tuesday July 28, 2009 at 12:53PM

Here's a fun one - how do you get RubyMine to access environment variables when you've got dependencies on those awful little things in your code and can't get around it? Well, assuming you're using a Mac (you are using a Mac, aren't you?), here's the magic incantation to get it to work:

vi ~/.MacOSX/environment.plist

and then...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>M2_REPO</key>
    <string>/Users/david/.m2/repository</string>
    <key>MAVEN_OPTS</key>
    <string>-XX:MaxPermSize=128m -Xmx512m</string>
  </dict>
</plist>

Then reboot your machine. Voila! Your environment variables should now be available for RubyMine (this works for IntelliJ Idea as well). Here's some additional information about environment.plist files, too.

David GoudreauDavid Goudreau
Rochambeau!!! Story estimation as representative democracy
edit Posted by David Goudreau on Thursday March 19, 2009 at 10:33PM

Here at Pivotal Labs we use our iteration planning meetings to not only hash out what we're going to work on in the upcoming iteration but to estimate any unestimated stories that are within striking distance of the upcoming iteration. (We often estimate 1 iteration + 1 week of stories in case we end up delivering more stories than our iteration expects us to).

Over the past couple of projects I've been involved in estimating stories truly as a team - no 'team lead' fiats, no hour-long conversations about every possible implementation under the sun. We've adopted the Rochambeau approach to help get a fairly quick gut-check estimation of a story from all developers at once. Also known as Rock-Paper-Scissors, the way this works is as follows:

  • Discuss an unestimated story for up to 5 minutes
  • Then, 1-2-3 and VOTE!

This approach has served us in a couple of ways:

  • The expectation for the developer is that we're looking for a rough estimate, not a precise measurement. This cuts down on endless technical one-upmanship.
  • The expectation for the customer is that developers have to have 1) general consensus among themselves about the risk/time/complexity of the story and 2) a defendable explanation of their estimation.

On my current project we use a 0,1,2,4,8 point scale for estimates, so each developer has 5 options to vote with. Even with this many possibilities, most stories end up with a clear general consensus and we go with that as the estimation, but in cases where there's a 50-50 split OR an estimation round where people's estimates are more than 1 level away from someone else in the group (for example, Paul votes for 1 point, George & Ringo vote for 2 points, and John votes for 4 points), that's a strong indicator that developer's assumptions are not all in line and that further clarification is required.

An added bonus is that the customers get to watch the developers vote in a concrete fashion and defend their estimates. That helps to bring the process more to life for them and to understand the concerns that we as developers have to regularly wrestle with. They also just love watching developers play RPS, I've come to discover.

For more information, check out this blog post for a discussion of team voting, spicy food, and photos.

David GoudreauDavid Goudreau
Standup 12/03/2008: Instance variables in Selenium
edit Posted by David Goudreau on Wednesday December 03, 2008 at 09:36AM

Help!

  • Instance variables in Selenium? We're setting up a User model instance in a setup method. We want to use that User instance in our test, naturally. But when we get into the test, the User instance has no methods on it. It's a standard Test::Unit Selenium test. Any ideas?
  • hoe/rake/rspec dependencies and CI? The following combination will break CI. The issue is that RSpec 1.1.11 depends on Hoe 1.8.2 and Hoe 1.8.2 requires Rake 0.8.3, which will break our CI environment. RubyGems may also need to get upgraded to get this combination to work. Sounds like a bit of work...
  • Uploaded file encodings? We're getting truncated content when uploading files encoded with ISO-8859-1 Windows. Any ideas why this is happening? Can we check the encoding when the file is uploaded?
  • Clock.now with a time zone in a named scope in the TEST Rails environment does not use the MockClock class (which lets us manipulate time in our tests). Why isn't it being used?
  • Demo environment DNS propagation & Apache configuration. The expected demo URL isn't working. It sounds like Ops just recently set the name in DNS so it's probably still getting propagated around.

Interesting Things

  • Apparently Treetop does not let you assume equality in the usual Ruby ways. Just something to look out for.
  • Last night we hosted a panel in conjunction with our partners Venture Archetypes called Project Startup. It's a regular panel we've been hosting for a while now. It happens roughly every 2 months.

David GoudreauDavid Goudreau
Standup 12/01/2008: Fun with libxml
edit Posted by David Goudreau on Monday December 01, 2008 at 10:03PM

Interesting Things

  • Libxml has been giving us some more strange behavior on Linux. If you do
parser = XML::Parser.new
parser.string = '<foo></foo>'
document = parser.parse

# Now watch me fail, but only on Linux!
parser.string = '<bar></bar>'
document = parser.parse
  • We're hosting a MagLev tech talk today compliments of Martin McClure.

  • Joseph Palermo has won the annual Pivotal Labs Mustache Competition. Granted, he was the only entry. But don't let that affect your admiration of his work. Photo to follow.

David GoudreauDavid Goudreau
Standup 02/29/08
edit Posted by David Goudreau on Friday February 29, 2008 at 05:30PM

Ask for Help

Other articles: