March 2007
12 posts
2 tags
Paginated Squirrel
Latest and greatest… 001 >> posts = Post.find(:all) do updated_on > 1.year.ago paginate :page => 4, :per_page => 10 end => [...] 005 >> posts.total_results => 46 006 >> posts.pages.current => 4 007 >> posts.pages.current_range => 31..40 008 >> posts.pages.next => 5 009 >> posts.pages.previous ...
Mar 30th
And then there was...
This has been feeling to me, lately, like the natural progression of things, especially with this sitting just around the corner…
Mar 29th
1 tag
Sometimes Too Much Is Too Much
Lately I’ve been working on a really interesting project, in Javascript actually. It looks like things are going well, so I’ll probably be posting here about it very soon when thoughtbot releases it to the public. But yesterday, I spent the afternoon getting really frustrated. For the life of me, I just couldn’t track down this error. I was angry…REALLY angry. Well, here, you can see for...
Mar 28th
I mock your fixtures
Testing is a beautiful thing. There are no words to describe the immense pleasure I get from writing a good test. When I first started here at Thoughtbot, I had been unexposed to the glory of testing. The days of writing code and then manually going through my application to make sure the changes I made worked the way I expected them to – are over. In the early days of my testing, I really...
Mar 26th
More testing goodness
So, as I hinted at some test helpers that we’ve been working on here at thoughtbot. Here’s what we’ve got going on for the models: class ArticleTest < Test::Unit::TestCase should_belong_to :article_type should_have_and_belong_to_many :products should_have_one :image should_have_many :widgets, :through => :widgetization should_require_attributes :author, :title, :body end Pretty...
Mar 23rd
1 tag
Lightening Up The Mood
For more than two months now, the thoughtbot guys have been enjoying a weekly round of poker. This has been an excellent opportunity to unwind, get to know each other a little better, and see each others apartments. Taking the opportunity to relax and have some healthy competition has been a lot of fun. Featured in the picture (from left to right) is Floyd, Eric T, Jared and Eric M (Floyd...
Mar 23rd
4 tags
Exploring Coding Guidelines
At thoughtbot we’ve recently started to redo our outdated coding standards. We’ve taken a “consider everything” approach. Making the easy decisions by fiat and then opening up some of the decisions to the discussion of the entire group (with one person given ultimate responsibility for making the decision). Its going well, but slowly, so far. When we did our original coding guidelines a few...
Mar 22nd
No code left untested
Why doesn’t Rails generate a test file for each of your helpers for each of your controllers? It should, I mean its code so you have to have tests for it. All that talk you normally hear about helpers “well helpers really should have any complicated code in them…etc.”, that’s great but it never works out that way. So I decided to extend Rails’ controller generator to generate a helper test file...
Mar 20th
Battle Royale - Testing
Overmocking makes tests brittle Let’s look at the controller action from the last post: And the proposed test: So what happens if we decide that the call to find should really be a search_by_name method on the User model? We refactor, the controller action becomes: And our tests break. Note that the functionality is the same, and normal tests would have passed to prove...
Mar 17th
Rails don't know testing
I’ve had enough of Rails testing, coming from other languages/frameworks that know the importance of testing, the more I test in Rails the more I miss ‘em. I don’t care how quick and easy I can make a web app in Rails, when it comes down to it, language, framework, whatever, it’s all about testing. So I decided to try real testing in Rails. By real testing, I mean tests where each test, only...
Mar 17th
specin rspec with rails
Using rSpec / Spec::Rails Installation is pretty simple, and is fully covered here. Here’s an example of some reasonable specs for a product model: context "An instance of Product" do fixtures :products setup do @product = Product.find(:first) end specify "should return lowest of list_price or our_price when sent price" do @product.should_receive(:our_price).and_return(1) ...
Mar 9th
1 tag
Operating Under The Confluence
At thoughtbot, we use 37signals’ Basecamp for project management, and Campfire for interoffice chat. But sometimes, circumstances beyond our control compel us to participate in Atlassian’s JIRA software. JIRA’s todos are called “issues”, and require certain permissions to mark issues as complete, resolved, confirmed, etc. I don’t have permissions to do any of these on many of the issues I’m...
Mar 2nd