Skip to content

Instantly share code, notes, and snippets.

View jameshd's full-sized avatar

James Hattersley-Dykes jameshd

View GitHub Profile
@jameshd
jameshd / README.md
Created May 20, 2021 15:29
Docusaurus Footer Override
@jameshd
jameshd / clean.sh
Created March 9, 2020 15:00
Slack Cleaner
#! /bin/bash
# You'll need python and pip installed + a slack token
# https://api.slack.com/legacy/custom-integrations/legacy-tokens
# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# python get-pip.py
# pip install slack-cleaner
## READ THE DOCS https://github.com/sgratzl/slack-cleaner
@jameshd
jameshd / test.js
Last active June 27, 2018 10:02
Loosely detecting JSON responses
// console.log(pm.response.headers.has('application/json')); doesn't work, too strict.
const isJsonResponse = (pm.response.headers.filter((header) => header.value.indexOf('application/json') !== -1).length > 0);
if (isJsonResponse) {
pm.test("it should match schema", () => {
const schema = {
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "#/definitions/Welcome",
"definitions": {
postman_api_key=<YOUR API KEY>
collection_uuid=<something here>
environment_uuid=<something here>
curl --request GET \
--url "https://api.getpostman.com/collections/$collection_uid" \
--header 'X-Api-Key: "$postman_api_key" > collection.json
curl --request GET \
--url https://api.getpostman.com/environments/$environment_uid" \
const expectedPropNumber = pm.environment.get("__proposal_id");
const expectedDecision = data.decision;
const $ = cheerio.load(pm.response.text());
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("it got the right proposal", function () {
const $ = cheerio.load(pm.response.text());
pm.test("it should return a propnumber", function(){
pm.expect($('proposalNumber').text()).to.not.be.empty;
});
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
@jameshd
jameshd / commit-msg.rb
Created March 22, 2016 15:09
JIRA Ticket Pre Commit Hook
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file);
regex = /([A-Z]{1,3}-\d{1,})/
if !message.start_with?('Merge') && !regex.match(message)
puts "Your commit message does not contain a JIRA ticket reference"
exit 1
end
@jameshd
jameshd / TestCase.php
Created January 2, 2015 08:34
WebDriver Factory Class
class E2ETestCase extends PHPUnit_Framework_TestCase
{
protected $driver;
public function setUp()
{
$this->driver = App_Factory_RemoteWebDriver::factory();
}
// more here.
@jameshd
jameshd / autofixture
Created October 20, 2014 11:37
autofixtures
// usage within a test
$autoFixture->setXml('/path/to/xml')
->setExpectations(
array(
1 => array('longName' => 'Lewis Hamilton'),
2 => array('shortName' => 'L Hmltn'),
3 => array('videCode' => 'LHTN')
// etc...
)