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.

Peter JarosPeter Jaros
NYC Standup Round-up for Feb 16th - Feb 19th
edit Posted by Peter Jaros on Friday February 19, 2010 at 02:16PM

Helps

  • Using bundler seems to break some Rails plugins which try to extend Rails objects, such as Loofah, and no one is sure why. Probably something in the load order is different. A "workaround" is to find other ways of including functionality in your models, such as including modules in an ApplicationModel base class, which you should probably do anyway. Still, does anyone know what's going wrong?

  • On a few of our Snow Leopard machines, we've seen git slow to a crawl. Rebooting seems to fix it temporarily. We haven't seen it on our Leopard machines. Anyone else seen this or have a fix?

Interesting

  • On one of our projects, we have a rake task called deployed:versions which sshes into each of our deployment boxes finds the git version which is deployed, and presents the results in a nice table. It's been a handy tool, and you may want to write one for yourself, especially if your project deploys to lots of boxes and environments like ours.

  • If you're using Snow Leopard and Firefox 3.6, you may have some issues with sqlite3 (of all things). Sauce Labs have fixed this in their Sauce RC, which is a replacement for Selenium RC. You don't have to use Sauce RC to get the fix; just download it and replace the JAR files in Selenium RC with theirs.

  • Speaking of Selenium did you know it has great drag and drop support? Here's a Cucumber step for dragging items in a jQuery UI Sortable list:

    When /^I drag "([^\"])" above "([^\"])"$/ do |dragged_item, dropped_item| li = lambda { |text| %{//ul[contains(@class,"ui-sortable")]/li[contains(string(),"#{text}")]} } selenium.drag_and_drop_to_object(li[dragged_item], li[dropped_item]) end

  • On one project, have a lot of commits called "WIP" ("Work in progress"). It's not a very useful message. Some people have taken to squashing their branches into a single commit before they put them on master. When there are lots of commits on a branch, this is also not very useful, as the details of what happened get lost. Instead, we're striving to give commits good names and not squash them. When we do need to make a WIP commit, such as when we push work in progress at the end of the day, we amend to it later and give it a meaningful name.

    When it's time to rebase onto master, you can do this:

    code(master)$ git rebase -i origin/master

    That -i means "interactive". Your editor can open, and you can tell git to squash meaningless commits into other commits they belong with. You'll get a chance to give the frankensteined beast a new commit message. You can also reorder, skip, or edit commits this way; see git help rebase for details.

Other articles: