jsmestad / stale_fish

keep file fixtures (canned responses) current in your application

This URL has Read+Write access

jsmestad (author)
Wed Jul 01 21:26:40 -0700 2009
commit  52a3279baa88a152161c6de7d08f5a46aa61cbd6
tree    c7b34dcd45a980abd6aa7e991a7440269c3423f9
parent  75b7e64ee7c85d892ddfded3c77d751cac26c21b
name age message
file .document Loading commit data...
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
file Rakefile
file VERSION
directory lib/
directory spec/
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.

How To

Simply drop in a YAML file in your application (for rails, RAILS_ROOT/config/stale_fish.yml is preferred) and issue the following commands.

A sample YAML file:

  ---
  stale:
    yahoo:
      filepath: ./tmp/yahoo.html
      source: http://www.yahoo.com
      updated:
      frequency: 1.day
    google:
      filepath: git_commit.json
      source: http://api.github.com/post_commit/
      updated:
      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:

  describe UsersController do
    before do
      StaleFish.load_config = "#{RAILS_ROOT}/config/stale_fish.yml"
      StaleFish.update_stale
    end
    ....
  end

For all tests:

  Spec::Runner.configure do |config|
    ...
    before do
      StaleFish.load_config = "#{RAILS_ROOT}/config/stale_fish.yml"
      StaleFish.update_stale
    end
    ....
  end

Copyright

Copyright © 2009 Justin Smestad. See LICENSE for details.