Skip to content

Instantly share code, notes, and snippets.

View nathanhumbert's full-sized avatar

Nathan Humbert nathanhumbert

View GitHub Profile
module God
module Conditions
class RestartFileTouched < PollCondition
attr_accessor :restart_file
def initialize
super
end
def process_start_time
Time.parse(`ps -o lstart -p #{self.watch.pid} --no-heading`)
should "create user" do
assert_difference('User.count') do
post :create, :user => {:username => "foo"}
end
end
context "create user" do
setup { post :create, :user => {:username => "foo"} }
should assign_to( :user ).with_kind_of(User)
should "save user to database" do
assert_equal false, assigns(:user).new_record?
end
end
<div class='field'>
<h3><a href="http://www.checkthesock.com/fields/walla-walla-valley-proptwisters">Walla Walla Valley Proptwisters</a></h3>
<p>Walla Walla, WA</p>
<p>
Coordinates:
<span class='lat'>46.04959</span>
<span class='lon'>-118.363727</span>
</p>
</div>
$(document).ready(function() {
var latlng = new google.maps.LatLng(39.98, -98.26);
var myOptions = {
zoom: 4,
center: latlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var infowindow = new google.maps.InfoWindow({content: ''});
class CachedMetar
def self.metar(icao)
Rails.cache.fetch("cached_metar_#{icao}", :expires_in => 5.minutes) do
CurrentMetar::Metar.get_metar(icao)
end
end
end
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
source :rubygems
gem 'sinatra'
require 'rubygems'
require 'bundler'
Bundler.require
require './myapp'
run MyApp
class MyApp < Sinatra::Base
get '/' do
'Hello world!'
end
end