Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
require_relative './setup_test_database'
ENV['RACK_ENV'] = 'test'
ENV['ENVIRONMENT'] = 'test'
# Bring in the contents of the `app.rb` file
require File.join(File.dirname(__FILE__), '..', 'app.rb')
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chris James, London - Software Engineer</title>
<meta charset="UTF-8"/>
<meta name="description" content="Chris James, London - Software Engineer" lang="en"/>
<meta name="viewport" content="width=device-width, minimumscale=
1.0, maximum-scale=1.0" />
<link rel="stylesheet" type="text/css" href="{{.CSSPath}}">
<link rel="alternate" type="application/rss+xml" title="RSS feed" href="/rss" />
address_book = {
"Chris" => "chris@james.com",
"Ruth" => "ruth@baker.com",
"Pepper" => "pepper@pot.com"
}
givers = address_book.keys.shuffle
receivers = givers.rotate(1)
givers_receivers = givers.zip(receivers)
@quii
quii / blah.go
Created August 4, 2018 20:16
Dependencies
package main
import (
"net/http"
"fmt"
)
type MessageGetter interface {
GetMessage() string
}
type LatLong struct{
Lat float64
Long float64
}
func (l LatLong) Generate(rand *rand.Rand, size int) reflect.Value{
randomLatLong := LatLong{
Lat: rand.Float64(),
Long: rand.Float64(),
}
func TestAddingExample(t *testing.T) {
result := add(3, 2)
if result != 5 {
t.Error("3 plus 2 is 5 but i got", result)
}
}
func add(x, y int) int {
return x + y
}
func TestAddingZeroMakesNoDifference(t *testing.T) {
/*
Create an assertion, which is a function that takes N inputs of
random data and returns true if the assertion passes.
In this case, we're saying take any random integer (x)
If you add 0, it should equal x
*/
assertion := func(x int) bool {
return add(x, 0) == x
func TestComplicatedThing(t *testing.T){
x := getRandomInt()
y := getRandomInt()
expected := complicated(x, y)
if expected != complicated(x, y){
// oh no..
}
}
func TestAddition(t *testing.T){
x := getRandomInt()
y := getRandomInt()
expected := x + y
if expected != add(x, y){
// oh no..
}