Skip to content

Instantly share code, notes, and snippets.

View masonforest's full-sized avatar

Mason Fischer masonforest

View GitHub Profile
render("Hello World");
@masonforest
masonforest / Dockerfile
Last active March 18, 2020 16:34
Test Drive Your Dockerfiles with RSpec and ServerSpec
FROM ubuntu:14.04
MAINTAINER Mason Fischer <mason@thoughtbot.com>
RUN apt-get update && apt-get install -y nodejs
var Docker = require('dockerode');
var docker = new Docker({ socketPath: false, host: '192.168.59.103', port: '2375' });
var optsc = {
'Hostname': '',
'User': '',
'AttachStdin': true,
'AttachStdout': true,
'AttachStderr': true,
'Tty': false,

Accounts

Create an account

POST /accounts

Input

  • account_id
@masonforest
masonforest / deliver_email_matcher.rb
Created May 17, 2013 22:00
rspec matcher for ActionMailer rails email delivery
# Usage
# order = create(:order)
#
# expect {
# order.pay!
# }.to deliver_email(OrderMailer, :paid, order.id)
#
#
{"ref":"refs/heads/master","after":"71875ba99b5109cbdfef770e590ba7504536eb53","before":"bb86ebb305cf27a94e2249ee1b0c8a96919bfa03","created":false,"deleted":false,"forced":false,"compare":"https://github.com/21x9/ServiceLog/compare/bb86ebb305cf...71875ba99b51","commits":[{"id":"171bbbae6646c0bc6bdabf2e0b0ea04392c86ce1","distinct":true,"message":"Fixed another bug related to the status bar disappearing after resigning from the photo view controller while the bars are hidden","timestamp":"2012-01-24T10:48:58-08:00","url":"https://github.com/21x9/ServiceLog/commit/171bbbae6646c0bc6bdabf2e0b0ea04392c86ce1","author":{"name":"Mark Adams","email":"mark.adams86@gmail.com","username":"21x9"},"committer":{"name":"Mark Adams","email":"mark.adams86@gmail.com","username":"21x9"},"added":[],"removed":[],"modified":["ServiceLog/PhotoViewerViewController.m"]},{"id":"417939bf185774585cedacf91dfc111260d30d8b","distinct":true,"message":"Fixed some interface stuff like disclosure indicators and the ability to select maintenance e
@masonforest
masonforest / gist:5199929
Last active December 15, 2015 04:09
validate USPS tracking numbers in Ruby
def valid(tracking_number)
chars = tracking_number.chars.to_a
expected_check_digit = chars.pop.to_i
total = 0
chars.reverse.each_with_index do |digit, index|
if index.even?
total += digit.to_i * 3
else
total += digit.to_i
@masonforest
masonforest / gist:4226449
Created December 6, 2012 17:46
How jQuery spies should work
describe "Quickpay.startQuickPay", ->
it "calls animate on .single_item_quick_pay", ->
quickPay = new Threadflip.QuickPay()
event = new jQuery.Event("click")
$('.single_item_quick_pay').spyOn('animate')
quickPay.startQuickPay(event)
expect($('.single_item_quick_pay').animate).toHaveBeenCalledWith({height: "300px"})
@masonforest
masonforest / gist:4226421
Created December 6, 2012 17:42
jQuery spies
describe "Quickpay.startQuickPay", ->
it "calls animate on .single_item_quick_pay", ->
quickPay = new Threadflip.QuickPay()
event = new jQuery.Event("click")
animateSpy = spyOn($.fn, "animate")
quickPay.startQuickPay(event)
expect($.fn.animate).toHaveBeenCalledWith({height: "300px"})
expect(animateSpy.mostRecentCall.object.selector).toEqual('.single_item_quick_pay')