Jacob Maine's blog
Help
"What's the best way to test that an array contains another array?"
A custom matcher using array - other_array was suggested.
Interesting
The team that was having problems with Prototype response codes found a partial solution.
They sometimes call abort() on the request which triggers the callbacks with a 0 response code. They found that if they set transport.onreadystatechange = function() {}; before calling abort() they could skip the callbacks, and manually call whatever clean-up they needed. That Prototype interprets 0 as a success still sounds strange.
A Palm project uses Prototype for their ajax calls. They noticed that Prototype casts low-level errors (network errors, etc.) to a response code of 0. Unfortunately, the rest of Prototype interprets 0 as "success". When they hacked Prototype to interpret 0 as a failure, another darker problem emerged. In some cases, for example if they send two requests in rapid succession, even if both responses have 200 in their headers, Prototype will report the second's response code as 0. So, 0 can indicate success or failure in different scenarios.
- Reminder: tonight we're hosting a workshop to help you polish your RailsConf presentation proposal. Sign up or just drop in. Thanks to our own Sarah Mei for coordinating and running the workshop.
- "Anyone familiar with the new RubyMine test runner? We'd like to integrate Jasmine tests, so we can run headless JS tests in the IDE."
When you kill a JRuby process (e.g. with a SIGINT) you can't bank on ensure blocks being executed. Of course, this is worrisome - file handles and other connections won't be closed. The problem boils down to this example:
$ cat kill_me.rb
begin
sleep
ensure
puts 'executed ensure'
end
$
$ ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
$
$ ruby kill_me.rb
^Cexecuted ensure
kill_me.rb:2:in `sleep': Interrupt
from kill_me.rb:2
$
$ jruby -v
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_13) [x86_64-java]
$
$ jruby kill_me.rb
^C$
Ask for Help
"Any really awesome scheduling tools out there?"
One project is looking for a nice GUI based scheduling tool that provides insight on and control over their jobs. They'd like to start and stop, reschedule, prioritize and monitor their queues and jobs. Why are all the solutions out there so enterprise-y ($$$)?
Interesting Things
- Maybe we'll learn the third time around. Selenium + transactional fixtures = pain. Turn transactional fixtures off.
Ask for Help
"We have an EngineYard slice that handles port 443 requests. From that box, we want to connect to a port 443 service, but we get directed to port 8443 instead. Any suggestions?"
We're using the box's external IP, beause we want to go back through the load balancer, so using the internal IP doesn't work.
Interesting Things
- The RubyConf CFP is out. Deadline is August 21st.
- The
named_scopechanges we were struggling with have been rolled back. If you liked the behavior we were having trouble with, we submitted a patch to allow that functionality, so add your +1 to the lighthouse ticket. - If you are using Google hosted javascript libraries, but didn't like all the calls to
google.load(...)in your code, you can now put them in the URL in thesrcattribute of yourscripttag. Though the documentation doesn't mention it, this works for all the libraries, including jQuery. - A number of issues with Spork, the rSpec server, and Desert, the Rails plugin framework, were unearthed. First, Spork requires that the string
RAILS_GEM_VERSIONappear in you environment file, even if it's commented out. It uses that to know you're running Rails. Second, because of the way Spork delays loading ofApplicationControllerandApplicationHelper, any changes to them require a restart of the Spork server. And finally, because Spork and Desert both manipulate load paths, they can step on each other. Not sure if there's a good workaround for this problem.
Ask for Help
"In addition to Delayed::Job any recommendations for background queuing?"
A project needs to run a series of interconnected sequential jobs in the background, probably with just one worker.
Interesting Things
- We are excited about progress on Bundler.
- We are ho-hum about Microhoo!.
Interesting Things
A few people have had problems with a change to named scope in Rails 2.3.3. The gist of the change is that if you chain named scopes, one of which uses a lambda that executes queries with the same model class, those queries are evaluated with the scope built up by the chain, not the default scope of the model.
with_exclusive_scopemay get around this, but could lose the default scope (or break things likeacts_as_paranoid).Rails 2.3.3 + Passenger fails with certain system configurations. Rails 2.3.3 does not bundle Rack, although 2.3.2 did. This may also be the cause of Mongrel failures someone noticed with script/server.
Ask for Help
"What's the best way to test that a controller (a) renders a partial and (b) passes the partial the right locals?"
Mocking render_template and the locals ends up mocking too much of the request cycle. Ideally, we'd like something like:
response.should render_partial("item", :locals => {:item => assigns[:item]})
"Hpricot breaks with xml elements named
param. Any suggestions?"
Works if we replace Hpricot with Nokogiri, so that may be the way to go.
Interesting Things
- A follow up on the problems using Fixture Scenarios with Rails 2.3.2: The fixture are loading twice, although it's not clear why. The second run barfs with a syntax error. Perhaps the first run doesn't properly close the fixture file?
- Raising the timeout fixed issues with S3 uploads over slow connections. It might also be more efficient. The timeout could stop a 90% complete upload, then kick off a retry (the gem has a 3 retry policy), which further clogs the tubes.







