Skip to content

Instantly share code, notes, and snippets.

View jfredett's full-sized avatar

Joe Fredette jfredett

View GitHub Profile
require 'spec_helper'
describe QuitCommand do
let(:terminal) { double('terminal', shutdown: true ) }
let(:command) { QuitCommand.new terminal }
context do
subject{ command }
#command_factory_spec.rb:
require 'spec_helper'
describe CommandFactory do
let(:factory) { CommandFactory.new nil }
subject { factory.command(:foo) }
context 'a thing' do
@jfredett
jfredett / gist:5039822
Created February 26, 2013 16:28 — forked from jgn/gist:2758806

Stuff I learned about Puppet

Chef vs Puppet

  • My blink is that in 2012 Puppet is safer and more productive.
  • Puppet is declarative, Chef procedural.
  • Puppet brings system into compliance (state), Chef "does" things (recipes).
  • Puppet has strong security practices; Chef has a toleration for loose security in Chef itself.
  • Puppet makes it very hard to get "outside the lines" or violate its strong opinions; in Chef this is routine.
# Version 2 -- the cool version
require 'redis'
require 'forwardable' #standard ruby library
class RedisTester
# this way, we create the instance and check to see it's running every time
# we ask for it automatically.
def redis
@redis ||= Redis.new
raise unless redis_is_running?
@redis
@jfredett
jfredett / gist:2400475
Created April 16, 2012 18:18 — forked from kevinzen/gist:2400225
Advice on DRYing this test up?
# Here's how I might do it, though I'd probably skip the shared_examples and just duplicate them. I feel
# like it hides things a bit too much otherwise. Given that it doesn't represent a _huge_ extraction, I wouldn't
# mind the duplication.
#
# I'm pretty sure that subject is preserved across shared example calls, if it's not, you might need to improvise.
#
shared_examples_for "Firefox browser" do
its(:browser) { should == "Firefox" }
its(:security) { should == :strong }
require 'minitest/autorun'
###
# Test to demonstrate TCO in Ruby. Tested in 1.9.2+
class TestTCO < MiniTest::Unit::TestCase
code = <<-eocode
class Facts
def fact_helper(n, res)
if n == 1
res
@jfredett
jfredett / hack.sh
Created April 1, 2012 02:28 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#