Skip to content

Instantly share code, notes, and snippets.

View d1rtyvans's full-sized avatar
:shipit:

Chris Scott d1rtyvans

:shipit:
View GitHub Profile
@d1rtyvans
d1rtyvans / dmg-install.sh
Last active April 6, 2020 15:43
Install a MacOS Application from a disk image on the internet
#!/usr/bin/env bash
set -e
APP_NAME="Postgres.app"
APP_DIR="/Applications"
VERSION="2.3.3e"
URL="https://github.com/PostgresApp/PostgresApp/releases/download/v${VERSION}/Postgres-${VERSION}-10-11-12.dmg"
if [ -d $APP_DIR/$APP_NAME ]; then
# app/services/results/create_export.rb
# Service object that exports assignments, transactions, and views data (for Whatify's analysis) to csv,
# uploads to Dropbox, and notifies our CEO who runs his analysis using Stata.
# Full test coverage and easy extendability
module Results
class CreateExport
def initialize
upload_spreadsheets
class StripeCharger
def initialize(email:, token:, order:)
@email = email
@token = token
@order = order
end
def create_charge
Stripe.api_key = ENV.fetch("STRIPE_SECRET_KEY")
charge if order.costs_money?
require "rails_helper"
RSpec.describe StripeCharger do
describe "#create_charge" do
context "if the user does not have a stripe_id" do
it "creates a charge and a stripe customer" do
user = create(:user, stripe_id: nil)
order = create(:order, user: user)
add_to_cart(order: order, meal: create(:meal))
@d1rtyvans
d1rtyvans / Fixed Collapsable Navbar.markdown
Last active January 12, 2016 02:31
Fixed Collapsable Navbar
# Test all of your attr_readers for any class (RSPEC)
def test_getters object, expected, dont_test=[]
object.instance_variables.each do |attribute|
attribute = attribute.to_s and attribute[0] = ''
unless dont_test.include? attribute
describe "##{attribute}" do
it "returns correct #{attribute}" do
expect(object.send(attribute)).to eq(expected[attribute.to_sym])
end