Peter Jaros's blog



Peter JarosPeter Jaros
NYC Standup Round-up for Mar 15th - Mar 19th
edit Posted by Peter Jaros on Friday March 19, 2010 at 03:07PM

Spring is just around the corner, and it has been a beautiful week here in sunny NYC. We've learned a lot this week, as you'll see as we do the Round-up!

Ask For Help

  • Kevin and I are having a heck of a time using Web Driver to drive an app that uses Google Maps. Whenever we click on or type into anything displayed on the map, the contents of the map (including the Google logo and the zoom control) move about 20 pixels up. Our tests seem to still work, it just looks like it's broken. Anyone else seen this or know what might cause it?

Interesting Things

  • Kevin and I discovered that Capybara's page.execute_script doesn't like to execute multiple statements. It really wants to evaluate a single expression. The upside of this is that it's really good at casting Javascript values into Ruby; it seems to work well with strings, numbers, and even arrays. If you really want to execute multiple statements, you can do this:

      page.execute_script <<-JS
        (function(){
          statement1();
          statement2();
          return someValue;
        })()
      JS
    
  • Todd found out the hard way that Ruby's String#sprintf (also seen as the String#%) will cast your string numbers to octal if you're not careful. Behold:

      >> "%d" % "010"
      => "8"
      >> "%d" % "08"
      ArgumentError: invalid value for Integer: "08"
        from (irb):2:in `%'
        from (irb):2
    

    Make sure you don't feed sprintf a string number that starts with a 0 unless you mean it to be octal.

  • Rachel tells us that there's an upcoming Rails workshop for women in NYC. Rumor has it that Pivotal's own Sarah Mei is behind it. She's been known to do such things before. Details as they become available.

  • Pat's improv show is tonight! Check him out at the Magnet Theater.

Peter JarosPeter Jaros
NYC Standup Round-up for Mar 8th - Mar 12th
edit Posted by Peter Jaros on Friday March 12, 2010 at 03:29PM

Spring is in the air here in sunny NYC! Well, it was sunny for a bit. Now it's turned into that classic film-noir drizzle. That's authentic New York weather outside our window as we do the Round Up!

Ask for Help

  • I asked, "In Jasmine, how do you spy on a constructor?" Suppose you have a constructor called Widget. Saying spyOn(window, "Widget") swaps out the real Widget function with a spy. The real Widget implementation takes its prototype with it, which means that Widgets created while the constructor is spied on don't get the methods a Widget would get. That's true even when you spy with spyOn(window, "Widget").andCallThrough().

    Also, there doesn't seem to be a way to stub out object construction and return an object of your choosing. In Rspec in Ruby you can say,

    Widget.should_receive(:new).and_return(my_fake_widget)

    because .new is a class method. But in Javascript, new is a keyword which always creates a new object. I'm guessing there's no good way around this, but if there is one, we could really use it.

    Update: This is, as it turns out, entirely incorrect. Jasmine's .andReturn() does let you stub constructors properly. I still have no idea how this works. See the comments for more discussion.

Interesting Stuff

  • Todd notifies us that in ActiveRecord, dynamic finders with too-few arguments fail silently. That is, if you say,

    Person.find_by_first_name_and_last_name_and_email("Todd", "Persen")

    and fail to specify a value for email, the value is taken to be nil. That means that the finder will look for someone named "Todd Persen" with a nil email address. You might have meant that. More likely, you made a mistake. AR should probably check the number of arguments it's given against the number of columns in the finder name.

  • You already know that Pivotal does real Extreme Programming. But did you know that we have...Extreme Breakfast?

Peter JarosPeter Jaros
NYC Standup Round-up for Mar 1st - Mar 5th
edit Posted by Peter Jaros on Friday March 05, 2010 at 01:04PM

It's been a quiet week in New York City, my hometown. Let's do the round-up.

Ask for Help

And that's it. I'll see you back here next week.

Peter JarosPeter Jaros
NYC Standup Round-up for Feb 22th - Feb 26th
edit Posted by Peter Jaros on Friday February 26, 2010 at 12:33PM

Live from the set of Snowpocalypse 4: The Reckoning, it's the weekly NYC Standup Round-up!

Interesting

  • Corey points out that the Google Maps embed code wants to be put directly on a page, not loaded on demand with something like jQuery's $.getScript(). Luckily, there's a fix: adding an async=2 param to the Google Maps API URL. More info in a post from Olly Hodgson.

  • Rachel and Pat found out the hard way that Bundler 0.9.8 doesn't run on Ruby 1.8.6. Upgrade your Ruby or stick to Bundler 0.9.7.

  • The same team had a real headache even upgrading from Bundler 0.7.0 to 0.9.8. The gem cache directory moves and the Gemfile format changes, among other things. This sounds like more than a minor-version change to your standup scribe.

  • Don't put Coca-Cola in the freezer. I know, you want it to get cold faster. You'll come back for them in like five minutes. It seems like a great idea. But out of sight, out of mind, and the next day, you open the freezer to grab your microwave burrito and you find these waiting to explode all over you:

    Oh ,the Cokemanity.

    I'm just asking you to think this through. Do you want frozen Coke foam splattered across your nice shirt? You can put an end to this madness. Just don't do it.