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_scriptdoesn’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; })() JSTodd found out the hard way that Ruby’s
String#sprintf(also seen as theString#%) 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):2Make sure you don’t feed
sprintfa string number that starts with a0unless 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.
010 is octal – it’s got nothing to do with #sprintf.
>> 010
=> 8
March 20, 2010 at 7:28 am
Right, you expect `010` to be octal. You don’t necessarily expect `”010″` to be taken as octal. In fact, `”010″.to_i == 10`”. But when it’s interpolated with `#sprintf`, it *is* taken as octal.
This occurred when we were doing data conversion from a legacy system which stored numeric identifiers as zero-padded strings, so we weren’t really thinking about it until it blew up.
March 20, 2010 at 7:44 am