- Testing blocks. If you have a block and you want to spy on the internals as it executes, what do you do? Suggestions were:
- Have each method called internally throw a symbol and check for that.
- Turn it into a proc, and set expectations on that.
- Stub the methods being called internally and set expectations on those.
- pass the block to a spy object.
Other suggestions welcome. The project is using rr, which apparently can’t do this last option, though that would be ideal.
- Routes in Rails are case-sensitive? /products/1/edit and /Products/1/edit don’t both resolve to the same place (unless you specify in routes.rb). Rumor has it that the RFC for URIs says that the path portion of a URL is case-sensitive, as opposed to the case-insensitive domain name.
If anyone wants to read through that document and confirm…feel free.
Yesterday we had Mat Brown of Patch.com giving us a presentation on his Sunspot gem for easily adding full-text search to a Rails application via Solr.
Mat walked us through the steps for adding Sunspot to a Rails application, talked through some of the production deployment concerns of Solr and illustrated some of the new features of Solr 1.4 such as master/slave replication and sharding that make it worth a look for full-text search.
Most of our tech talks are open to the public. If you’re interested in joining us for presentations like this please join our mailing list.
That’s it. I’m done with TextMate. It hasn’t been updated in over 2 years, either for essential functionality (replace in path) or performance fixes (searching through log files) or UI issues (how many boxes must you click to enable autosave?) or bug fixes. Every few months the author pokes his head up and says “I’m working on TextMate 3.0!” and then disappears again, happily accepting new license fees into his PayPal account.
I’ve just been bitten twice in two weeks by a bug that caused not just data loss, but data mangling in a way that was very difficult to fix. Here’s the rough steps to reproduce:
- Edit some files in TextMate
- Leave TextMate running in the foreground
- Switch to console and “git pull” in the latest code from your workmates
- Run a search-and-replace that edits a file that was changed (by someone else) during the merge
- Save that edit
You’ll see (with “git diff”) that your version of the file has your new post-merge changes… but it also has reverted your buddy’s changes from the merge. It’s like you decided that those changes were no good and reverted them yourself and then added your own.
If you fail to notice this before checking in, you will totally hose your version control… but just for that one file. You can’t just revert a whole commit… you’ll have to step through change by change to figure out which change was theirs, which change was yours, and which change looks like it was yours but was actually an inadvertent revert of theirs!
I can’t work under these conditions. I’m switching to RubyMine today. See http://bjclark.me/2010/03/10/rubymine-a-love-story/ for why.
P.S. I just found a bug report for this dated 2008-04-02. That’s just about 2 years ago for a critical data-losing bug. Woot.
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
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
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,
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.
Todd notifies us that in ActiveRecord, dynamic finders with too-few arguments fail silently. That is, if you say,
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?
Q: How can I plot thousands of points on a Google Map without said map being undraggable?
A: It may make sense to use Google’s HeatMap API after the number of plotted points exceeds 500. Other strategies are discussed here: Handling Large Amounts of Markers in Google Maps
Using ReCSS with Sass.
If you happen to be using SASS you can still make use of awesome ReCSS bookmarklets (including one by Pivotal’s own Erik Hanson) by using the compass command line tool and watching your project for changes. Totally rad!
Ruby Enterprise Edition
Is awesome, if you use the garbage collection tweaks. One team installed it and saw a 50% savings in their test suite running times — over 15 minutes! Combined with parallel spec it can be a real winner. If you’re on Leopard, you may need to install the version from Oct 2009, as the latest fails with a Marshall.load error on install. 2 legit!
All your RubyMine problems can be fixed!
By reverting to RubyMine 1.1.1. At least if your problems are: inconsistent functionality with the merge tool, and RubyMine occasionally refusing to recognize spec files correctly. That’s def!
Spring Forward this Sunday to save the daylight, and terrorize the programmers. Thanks a lot, farmers-slash-botanists. WORD Y’ALL. I’M OUT.
Making truly awesome stuff is hard. Pivot Carl Coryell-Martin proposes we identify common physiological responses and condense their design solutions into a pattern language. He presents a draft set of patterns in the context of crafting an iPhone app.
See all our talks at http://pivotallabs.com/talks
David Pollak and Martin Odersky discuss the power of Lift, a Rails-like framework for Scala. David is the maintainer of the Lift framework and Martin is the author of Scala. Together they live-code a 30-line, real time, web based chat app in Lift and discuss the Scala constructs that allow for such concise applications.
See all our talks at http://pivotallabs.com/talks