How I Use Autotest

Eric Hodel | Mon, 26 Nov 2007 22:33:23 GMT

During the Q&A portion of my talk, I was asked a very important question about autotest, something like “How often do you save when using autotest?” I save all the time when using autotest. There was a followup question, something like “Don’t you get syntax errors?” and I don’t.

Before I wrote autotest I was making fine-grained saves that were syntactically correct. I wrote autotest to automate the running of tests so I wouldn’t have to choose which tests to run. My changes were so small that I spent an annoying fraction of my time editing my command line.

When I’m using autotest, rather than writing all of a method’s tests, I start by performing the setup (which should cause an error), add a flunk, and save, which is usually four lines:

  def test_blah
    result = @thingy.blah
    flunk
  end

When the tests run they’ll see the method blah doesn’t exist and fail, so I define the method, (the def blah and end lines), and save. Then I write an assertion and save the test, which will fail, so I implement what I need to make the assertion pass, and save. Now I repeatedly perform the minimum changes to go from failure to flunking until my test is complete, remove the flunk, and start over with the next method.

Each save I do is a handful of lines, so it’s easy to keep them syntactically correct. I know I’m going from working state to working state as I work towards my end goal so I can easily roll back my changes with undo.

Posted in ,  | 1 comment

RubyGems 0.9.5

Eric Hodel | Tue, 20 Nov 2007 00:35:31 GMT

RubyGems 0.9.5 adds several new features and fixes several bugs.

To upgrade to the latest RubyGems:

gem update --system

To upgrade to the latest RubyGems by hand:

  1. Download RubyGems from http://rubyforge.org/frs/?group_id=126&release_id=16500
  2. gem install rubygems-update-0.9.5.gem
  3. update_rubygems

To install RubyGems from scratch:

  1. Download RubyGems source .tgz or .zip file from http://rubyforge.org/frs/?group_id=126&release_id=16500
  2. Unpack the source .tgz or .zip
  3. ruby setup.rb

To install RubyGems on Ruby 1.9 update your ruby trunk checkout and reinstall.

To file bugs:

http://rubyforge.org/tracker/?func=add&group_id=126&atid=575

When filing a bug, gem env output will be helpful in diagnosing the issue.

If you find a bug where RubyGems crashes, please provide debug output. You can do that with gem --debug the_command. For example:

<samp>$ gem --debug unknown_command
Exception `RuntimeError' at [...]/rubygems/command_manager.rb:114 - Unknown command unknown_command
ERROR:  While executing gem ... (RuntimeError)
    Unknown command unknown_command
        [...]/rubygems/command_manager.rb:114:in `find_command'
        [...]/rubygems/command_manager.rb:103:in `process_args'
        [...]/rubygems/command_manager.rb:74:in `run'
        [...]/rubygems/gem_runner.rb:39:in `run'
        /usr/local/bin/gem:22</samp>

Changes

Select new features include:

  • Automatic installation of platform gems
  • New bandwidth and memory friendlier index file format
  • “Offline” mode (—no-update-sources)
  • Bulk update threshold can be specified (-B,—bulk-threshold)
  • New gem fetch command
  • gem now has “really verbose” output when you specify -v
  • Ruby 1.9 compatible

Other changes include:

  • Time::today is deprecated and will be removed at a future date
  • gem install --include-dependencies (-y) is now deprecated since it is the default, use—ignore-dependencies to turn off automatic dependency installation
  • gem.bat and bin stubs on mswin platforms are improved and compatible with the One-Click Installer
  • Multi-version diamond dependencies only are installed once
  • Bulk index updates take less memory
  • -V now enables verbose instead of -v to avoid collision with—version’s -v
  • gem install -i makes sure all depenencies are installed
  • gem update --system reinstalls into the prefix it was originally installed in
  • gem update --system respects—no-rdoc and—no-ri flags
  • HTTP basic authentication support for proxies
  • Gem::Specification#platforms should no longer be a String, use Gem::Platform::CURRENT when building binary gems instead
  • gem env has more diagnostic information
  • require ‘rubygems’ loads less code
  • sources.gem is gone, RubyGems now uses built-in defaults
  • gem install --source will no longer add—source by default, use gem sources --add to make it a permanent extra source
  • gem query (list) no longer prints details by default
  • Exact gem names are matched in various places
  • mkrf extensions are now supported
  • A gem can depend on a specific RubyGems version
  • gem_server is now gem server
  • gemlock is now gem lock
  • gem_mirror is now gem mirror
  • gemwhich is now gem which
  • gemri is no longer included with RubyGems
  • index_gem_repository.rb is now gem generate_index
  • gem performs more validation of parameters
  • Removed gem* commands are now replaced with stubs that warn
  • Custom rdoc styles are now supported
  • Gem indexer no longer removes quick index during index creation
  • Kernel#require only rescues a LoadError for the file being required now
  • gem dependencies can now display some information for remote gems

Notes and issues:

  • Old gem scripts (gem_mirror, gem_server, gemlock, gemri, gemwhich, index_gem_repository.rb) are not cleaned up
  • There still appears to be a bug related to bulk updates of YAML indexes

Special Thanks

  • Daniel Berger for win32 support and testing
  • Luis Lavena for win32 support and testing
  • Tom Copeland for help testing and releasing the new indexer
  • Wilson Bilkovich for the new Marshal index format
  • To the rest of the RubyGems bug reporters and patch contributors

The full set of changes including contributors is included in the ChangeLog.

Platforms

RubyGems now automatically handles platform gems. This means that gem install will no longer prompt for gem selection. RubyGems uses Ruby’s built-in configuration to match the running ruby’s platform to choose the correct gem to install. The automatically chosen platform may be overridden with the—platform option.

The dependency, fetch, install, outdated, specification, uninstall and update commands all respond to—platform.

For more information, see gem help platforms

Thanks

Keep those gems coming!

—Jim & Chad & Eric (for the RubyGems team)

Posted in ,  | 13 comments

RubyConf 2007

Eric Hodel | Tue, 20 Nov 2007 00:32:50 GMT

I had a good time at RubyConf, but was too busy obsessing over my presentation. I think it turned out well, though, as many people complimented me on my talk. I did manage to play my “you owe me a beer” card a couple times though, which was good.

Oh, yes, here’s my slides for Maximizing Productivity in PDF, the Keynote (zipped) form, and the presentation courtesy of Confreaks.

This RubyConf had the feel of the pre-Rails RubyConfs, which was very welcome. The dual track format was alright, except that one talk would be far more popular than the other leaving one room standing-room-only.

I think my favorite talk of the conference was Ben Bleything’s Controlling Electronics with Ruby, because he had all sorts of fun toys to pass around and play with.

Also, Rich Kilmer, Akira Tanaka and Koichi Sasada figured out the last issues to importing RubyGems into 1.9, so we’ll be cleaning that up over the next week or two. I’ll have a separate post on the RubyGems differences between 1.8 and 1.9 shortly.

Posted in ,  | 1 comment