Blake Mizerany of Heroku talks about building lightweight RESTful web services with his Ruby framework Sinatra.
Giving your fake acts_as_fu model the same name as an actual model you have can lead to very obscure test failures. For those not in the know, acts_as_fu gives you the ability to test your model extensions directly by creating a fake model in your tests and mixing your extensions into it.
A few people have been using Paperclip to manage their attachments and have found it easier to integrate than Attachment_fu.
While this has been mentioned before, naming an ActiveRecord association
:target will cause infinite recursion. Especially lame if you are building an app for assassins or mobsters.
The tracker team upgraded to 2.2 and saw a big increase in the size of their mongrels, and much longer start-up times.
In an erector widget it appears that
respond_to? checks arity. For example:
self.respond_to?("some_method") # => false self.respond_to?("some_method", some_value) # => true
Here’s the gist of this post: gist.github.com/58876
Ever since I’ve started using Webrat, a lot of the pain of Selenium has gone away
for me. There’s still a little bit of pain though. Part of it is caused by the fact
in your current window under test. Well no more. Here’s a helper:
To use it with Cucumber, do like so:
World do |world| world.extend(SeleniumHelpers) world end
To use it with POS, do like so:
that it’s always going to return a
String, so you may have to massage the output
While Webrat’s DSL for traversing web apps is awesome, I’ve always found the
alternatives (Polonium for example) to not jive well with how I think. They’re
way better than talking directly to Selenium, you’re still locked in to a certain
fit your own style.
Now you can write your tests like so:
Credit should go to Brian Takita, since he did most of the hard work and I just wrote a method. Let me
know if you have any issues or ideas with the helper, and may all your tests be green.
Andrew Cantino and Kyle Maxwell talk about Parselets.com, a cross-language toolset for developer-generated APIs, and SelectorGadget, their bookmarklet that finds the minimal CSS selector for elements on the page.
Tammer Saleh of thoughtbot demonstrates Hoptoad, their Rails exception notification service. By aggregating repeat error notifications Hoptoad stops the email onslaught from a production bug while still providing appropriate notification and escalation.
Ezra Zygmuntowicz of Engine Yard demonstrates Solo, their new cloud offering for the deployment and management of lightweight Rails, Merb, or Rack apps.
Integer("008") != "008".to_i
to_imethod is what you want, unless you want exceptions or octal numbers.
Somebody needed help constructing a
named_scopewhere they could reference the count of an associated
has_manyassociation. There was some grumbling about using
:group(and if you do this, be sure not to call
counton the scope itself without also doing a
:select => 'DISTINCT primary_key'). The winning solution was to just put a counter_cache on the association and use the denormalized column instead.
Somebody was seeing mongrels hang when using an older copy of the S3 gem. It turned out the older version had the option for persistent connections defaulting to true. Setting
:persistent => falseor using a newer version that has
falseas the default fixed their problem
One of our sites was seeing a unbalanced distribution of requests despite the fact that the load balancer was evenly distributing connections. One host typically had 2x the traffic of the others, and it would switch every few hours to be a different host. It turned out to be the Google crawler, which uses a keepalive, getting stuck on a single host and making a lot of requests. The load balancer is only able to balance TCP connections, which Google is only using a single one of. The likely solution will be haproxy or something similar in front of the hosts to better distribute traffic.
Tired of refreshing your page to view changes in your CSS? Erik Hanson has a bookmarklet you can use without refreshing your page. See it on his blog.
There is a beta version of the Selenium 1.1.15 gem that includes the latest selenium-server.jar (1.0 beta-2). This fixes some problems with using Firefox 3. You can get the gem here, and you can read the details here.
- Shotgun is an automatic reloading version of the rackup command that’s shipped with Rack.
Rails by default stores its session in a browser cookie as an encrypted string. If you want to get the contents of that cookie from within Rails, you can call “
session.dbman.send :marshal, session.data“. If you want to get that value from tests, you’ll have to use an integration test, as functional tests mock out too much of the session store.
Ian McFarland and I spoke to Priya Ganapati of Wired this morning about the Palm Pre, webOS and Mojo Application Framework. It was a follow-on interview to Mitch Allen’s Webcast this morning. (Check http://developer.palm.com for the webcast; it will be posted soon.)
Check out the Wired blog post at: