Sarah MeiSarah Mei
Standup for St. Patrick's Day
edit Posted by Sarah Mei on Wednesday March 17, 2010 at 09:23AM

Help:

  • 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.

Sarah MeiSarah Mei
Standup 3/16/2010
edit Posted by Sarah Mei on Tuesday March 16, 2010 at 09:14AM

Help

Interesting

  • The on302 callback is a myth! One team discovered that if you set a 302 (redirect) callback for an AJAX call, like in Prototype, the redirect is followed by the browser and the callback is never called. Suggestions: hack the library so that if the response URL doesn't equal the request URL, call the on302. Or do that in your application Javascript.

Sarah MeiSarah Mei
Standup for the Ides of March
edit Posted by Sarah Mei on Monday March 15, 2010 at 09:16AM

Help

  • One team is starting to use Sunspot and is curious about testing strategies. Sunspot provides a method that stubs out the backend, but search blocks aren't executed, so it's hard to test actual searching.

  • Objective C needs a BDD framework. How does Xcode magically know about OCunit? We need to hook in there to have a usable framework.

Interesting

  • Mountain West Ruby Conf was awesome.

Carl Coryell-MartinCarl Coryell-Martin
SF Standup Feb 26, 2010: Golden Gate Ruby Conf Dates!
edit Posted by Carl Coryell-Martin on Friday February 26, 2010 at 09:21AM

Asking for Help

"Reloading model associations in Rails doesn't do what you expect it to do."

If you have a has_one relationship between the parent and the child and you reload the association, rails 2.3.2 will do a 'select * limit 1;' from the child table which is not what you want.

"How do I get the debugger in RubyMine to load my fixtures?"

So apparently the debugger built into ruby mine is using a different database connection that doesn't see the fixtures. Probably because they are built in an uncommitted transaction. The command line debugger doesn't have this problem.

Interesting Things

Carl Coryell-MartinCarl Coryell-Martin
SF Standup Feb 24, 2010: Chasing Down Obscure Error Messages
edit Posted by Carl Coryell-Martin on Wednesday February 24, 2010 at 09:34AM

Interesting Things Today

  • Message "undefined method 'join'" on gem installation during deployment to Engine Yard turned out to be the result of an upgrade of RubyGems from 1.3.5 to 1.3.6. The new version no longer requires stringio which broke bundler 0.8.1. The solution was to install the gem bundler08 -v0.8.4 on the server and then rerun 'gem bundle.'

  • A mysql 'Error 139' was traced to a mysql 5.0 innodb table that had enough varchar(255) and text columns such that the total bytes in the row exceeded 8k bytes. This is allegedly fixed in 6.0 (maybe 5.1).

  • Finally a team noticed the new 'touch' option in rails 2.3.4 on has_many and belongs_to attribute that allows you to update the updated_at attribute of child and parent objects. They'd implemented their own observer pattern to do the same thing but this was much easier.

Carl Coryell-MartinCarl Coryell-Martin
SF Standup Feb 23, 2010: Bleeding edges break things
edit Posted by Carl Coryell-Martin on Tuesday February 23, 2010 at 09:50AM

Interesting Things

  • One project attempted upgrading the newrelic rpm to version 2.10.3 and 2.10.4 but it broke delayed_job. The fix was to down grade newrelic to version 2.9.9.

  • Ruby versions above 1.8.7 patch level 174 are not stable with RVM. Incidentally this is the version of ruby that ships with snow leopard.

One Question:

  • What's the best practice for configuring services that notify users between development, staging and production? You really don't want to send out a million email notifications by mistake when you are testing the staging version of a service. If you put the switch in the database, it could lead to the production database being moved to staging or development and sending out erroneous notifications. Putting the switch in an environment variable means that it's difficult to test the staging server with some sample data.

Some Answers:

  • Some projects encrypt credentials for the different environments with different keys, thus the production credentials will absolutely not be available to the staging servers. (This can be hassle because you get exceptions when you try to use the real credentials in a staging environment with the different key.) Doing this means that you can inject test data into the staging environment encrypted with the staging keys and use that without risk of mistakenly sending notifications to real users.

  • Consider wrapping the API in question with a fake that only talks to the real world in the production environment.

  • Perhaps you could set up a rake task that manages the state of a live versus test notification.

Andrew CantinoAndrew Cantino
Standup 2/11/2010: Sass with Jasmine
edit Posted by Andrew Cantino on Thursday February 11, 2010 at 09:24AM

Interesting Things

  • If you are testing with jasmine, it's a good idea to include your CSS files in the test runner. This prevents, for example, issues where you've hidden an element in the CSS and expect it to be visible in your JavaScript. If you are using Sass, then you should regenerate your CSS from the Sass before running the jasmine tests. The current version of haml-edge updates the sass command-line tool with an update command. On one of our client projects, we added the following to our jasmine_config.rb file:
  def update_sass
    puts "Updating sass files..."
    rails_root = File.expand_path(File.dirname(__FILE__) + "/../../../")
    sass_path = "#{rails_root}/vendor/bundler_gems/ruby/1.8/gems/haml-edge-2.*/bin/sass"
    puts `#{sass_path} --update #{rails_root}/app/stylesheets:#{rails_root}/public/stylesheets/generated`
    puts "done."
  end

  alias_method :old_start, :start
  def start(*args)
    update_sass
    old_start(*args)
  end

  alias_method :old_start_server, :start_server
  def start_server(*args)
    update_sass
    old_start_server *args
  end

Andrew CantinoAndrew Cantino
Standup 2/10/2010: Calling all railsplugins.org
edit Posted by Andrew Cantino on Wednesday February 10, 2010 at 09:10AM

Interesting Things

  • When testing with jasmine and using jQuery live events, be sure to stop the events between tests. If you don't, they can cross tests and cause confusing results.
  • RailsPlugins.org is asking that all Rails plugin developers register their plugins on the site. This will both help determine the set of plugins that are ready for Rails 3, and also provide a comprehensive directory of plugins.

Interesting Things

  • Bundler is now at version 0.9.x. The 0.8 to 0.9 release included many improvements and large internal changes. Everyone should probably upgrade, but be aware that this may be disruptive to your project, as the bundle command has changed names. You should be aware of this before upgrading. Yehuda has posted a comprehensive blog post about using Bundler that is worth reading. Since Bundler is in beta, it will probably keep changing.
  • Amazon has released a beta versioning feature for S3 that allows you to keep a full history of changes to your S3 objects. This looks useful.
  • There is some question about what state of a DOM node is shown in the Safari console when console.debug is called. Is it the state of the DOM node from exactly when the call was made, or is it some later state due to Safari asynchronously displaying the console messages? We are going to do some research and will update at a future standup.

Edit:

It sounds like the Safari issue occurs when logging a reference. Mentioned workarounds for the Safari issue include:

  • explicitly logging the variables that you are interested in; i.e., console.log(obj.a, obj.b)
  • using the debugger
  • transforming the object to JSON
  • using console.dir
  • logging a string

Andrew CantinoAndrew Cantino
Standup 2/8/2010: Potential Geminstaller issues
edit Posted by Andrew Cantino on Monday February 08, 2010 at 10:23AM

Interesting Things

A project reported that GemInstaller failed when installing Rails 2.2.2, because it attempted to list the remote Rails 3.0.beta gem. There's a bug open and awaiting more info, but since this is not reproducible on RubyGems 1.3.5, it may be due to an old RubyGems version not handling prerelease gems properly.

The GemInstaller author heartily recommends that you switch to Bundler anyway

Other articles: