No release in over 3 years
Low commit activity in last 3 years
Stub HTTP responses
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Stale Fish¶ ↑

StaleFish is a utility for storing web requests as fixtures, faking web requests, and ensuring fixtures stay fresh by checking request at periodic intervals. It works at a global level, without modifying code or writing extensive stubs.

NOTICE¶ ↑

1.3.x is a complete rewrite of the StaleFish utility. It is incompatible with previous versions of StaleFish.

Features¶ ↑

  • Manage FakeWeb through StaleFish

  • Fixtures are updated based on a per-fixture update interval

  • Fixture update interval supports the ActiveSupport relative time DSL (ex. ‘30.minutes’, ‘2.days’, ‘1.year’)

  • Configuration file and fixture data is version control friendly

  • Specify which fixtures are checked for freshness using :all, :only, & :except arguement options

  • Force update of all fixtures regardless of freshness (bypass freshness check)

  • Test Framework agnostic (tested with Test::Unit & RSpec)

How To¶ ↑

Simply drop in a YAML file in your application (recommended location: {test/spec}/fixtures/stale_fish.yml) and issue the following commands.

A sample YAML file:

--- !omap
- stale:
  - twitter:                                        # fixture name (this must be unique)
    file: 'timeline.json'                           # fixture save location
    update_interval: 30.days                        # update interval
    check_against: http://twitter.com/api/timeline  # data to update fixture with when stale
    request_type: POST                              # request type to use when updating: GET, POST
    update_method: StaleFishFixture.update_me       # optional: this method is evaluated for a response instead of hitting the check_against param
    last_updated_at:                                # timestamp of last fixture update (can be left blank)
  - gh_commits:
    file: 'commits.xml'
    update_interval: 3.days
    check_against: http://api.github.com/commits.xml
    request_type: GET
    last_updated_at:

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

For all tests add the following to spec_helper.rb

require 'stale_fish'

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

Test::Unit¶ ↑

For all tests add the following to test_helper.rb

class Test::Unit::TestCase
  ...
  setup do
    StaleFish.update_stale
  end
  ...
end

More Info¶ ↑

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

Thanks¶ ↑

This utility uses FakeWeb, thanks to those contributors for their excellent work.

Copyright © 2009-2010 Justin Smestad. See LICENSE for details.