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
# 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') |
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
<!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" /> |
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
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) |
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
package main | |
import ( | |
"net/http" | |
"fmt" | |
) | |
type MessageGetter interface { | |
GetMessage() string | |
} |
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
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(), | |
} |
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
func TestAddingExample(t *testing.T) { | |
result := add(3, 2) | |
if result != 5 { | |
t.Error("3 plus 2 is 5 but i got", result) | |
} | |
} |
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
func add(x, y int) int { | |
return x + y | |
} |
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
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 |
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
func TestComplicatedThing(t *testing.T){ | |
x := getRandomInt() | |
y := getRandomInt() | |
expected := complicated(x, y) | |
if expected != complicated(x, y){ | |
// oh no.. | |
} | |
} |
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
func TestAddition(t *testing.T){ | |
x := getRandomInt() | |
y := getRandomInt() | |
expected := x + y | |
if expected != add(x, y){ | |
// oh no.. | |
} |