This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |