jsmestad / stale_fish

keep file fixtures (canned responses) current in your application

This URL has Read+Write access

name age message
file .gitignore Fri Jun 26 14:18:08 -0700 2009 basic release [jsmestad]
file LICENSE Fri Jun 26 12:13:11 -0700 2009 yaml syntax checking and loader completed. [jsmestad]
file README.rdoc Fri Oct 02 15:24:50 -0700 2009 updated README with file_path info [jsmestad]
file Rakefile Loading commit data...
file VERSION Sat Oct 03 22:50:44 -0700 2009 Version bump to 1.2.5 [jsmestad]
directory lib/
directory spec/
file stale_fish.gemspec Sun Oct 04 03:05:00 -0700 2009 Regenerated gemspec for version 1.2.5 [jsmestad]
directory tmp/ Fri Jun 26 14:18:08 -0700 2009 basic release [jsmestad]
README.rdoc

Stale Fish

This gem provides a method for keeping your fixtures in sync with their sources. This will prevent the scenario where your build is broken in production, but CI has a green build to do outdated fixture data. StaleFish also allows for FakeWeb integration and URI management.

Features

  • Fixture update frequency uses the ActiveSupport relative time DSL
  • Versioned configuration file & fixtures means fixtures are only updated once per project.
  • Manage FakeWeb stubbed URI’s through StaleFish
  • Automatic detection for Rails & Rack apps (default configuration locations)
  • Test Framework agnostic (tested with Test::Unit & RSpec)
  • Update all fixtures, specified fixtures, or forced update are all supported through the StaleFish.update_stale(*args) method
  • Fixtures are ONLY updated when a valid HTTP request is made, if server returns anything other than 200, an error is thrown failing the tests.

How To

Simply drop in a YAML file in your application (default location: {test/spec}/stale_fish.yml; overwrite by setting StaleFish::Utility.config_path) and issue the following commands.

A sample YAML file:

  stale:
    configuration:
      use_fakeweb: true
    yahoo:
      file_path: RAILS_ROOT + '/spec/fixtures/yahoo.html'
      source_url: http://www.yahoo.com
      last_updated_at:
      update_frequency: 1.day
    google:
      file_path:  RAILS_ROOT + '/spec/fixtures/github_commit.json'
      source_url: http://api.github.com/post_commit/
      last_updated_at:
      update_frequency: 2.weeks

Specify one block for every fixture you would like to update. The frequency field takes any relative date included in the ActiveSupport library.

RSpec

For a single test add it to a before block

  describe UsersController do
    before do
      StaleFish.update_stale("facebook", "yahoo")
    end
    ....
  end

For all tests add the following to spec_helper.rb

  require 'stale_fish'

  Spec::Runner.configure do |config|
    ...
    config.before do
      StaleFish.update_stale
    end
    ....
  end

Test::Unit

For all tests add the following to test_helper.rb

  class Test::Unit::TestCase
    ...
    self.use_transactional_fixtures = true
    self.use_instantiated_fixtures  = false
    ...
    setup do
      StaleFish.update_stale
    end
    ...
  end

More Info

View the wiki: wiki.github.com/jsmestad/stale_fish

Thanks

Paul Sadauskas for his work on Resourceful (used by StaleFish to provide accurate http handling when updating fixtures)

Copyright

Copyright © 2009 Justin Smestad. See LICENSE for details.