Skip to content

Instantly share code, notes, and snippets.

@nathanhumbert
Created January 24, 2011 02:20
Show Gist options
  • Save nathanhumbert/792716 to your computer and use it in GitHub Desktop.
Save nathanhumbert/792716 to your computer and use it in GitHub Desktop.
require 'test_helper'
class CachedMetarTest < ActiveSupport::TestCase
context 'self.metar' do
should 'call get_metar when cache is empty' do
Rails.cache.delete('cached_metar_test_icao')
CurrentMetar::Metar.expects(:get_metar).with('test_icao').returns('test')
assert_equal 'test', CachedMetar.metar('test_icao')
end
should 'return cached value without calling get_metar' do
Rails.cache.write('cached_metar_test_icao', 'test', :expires_in => 5.minutes)
CurrentMetar::Metar.expects(:get_metar).never
assert_equal 'test', CachedMetar.metar('test_icao')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment