Skip to content

Instantly share code, notes, and snippets.

Currently in the garden. Will be back in (Australian) Winter.

Beth Skurrie bethesque

Currently in the garden. Will be back in (Australian) Winter.
Block or report user

Report or block bethesque

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
bethesque / Gemfile
Last active Aug 29, 2015
Write a pact without a consumer
View Gemfile
source ''
gem 'pact', '~>1.7.0'
bethesque / task.rb
Created Apr 21, 2015
Ordered provider verification
View task.rb
require 'pact/provider/proxy/tasks' :userapi_service do | task |
task.pact_url './spec/pacts/userapi_service_consumer-userapi_service_provider.json'
task.provider_base_url ''
end :otherapi_service do | task |
task.pact_url './spec/pacts/otherapi_service_consumer-otherapi_service_provider.json'
task.provider_base_url ''
bethesque /
Last active Aug 29, 2015
Using Github oauth with the pact broker
# gem "omniauth-github"
# gem "rack-rewrite"
require 'fileutils'
require 'logger'
require 'sequel'
require 'pact_broker'
require 'omniauth/strategies/github'
require 'rack/rewrite'
bethesque /
Last active Aug 29, 2015
An appropach to writing tests

Our tests should:

  1. Assure us that the code is behaving correctly.
  2. Allow us to refactor with confidence.
  3. Help us write more maintainable code.

A process to help you write tests that achieve these goals

  1. Choose the part of the code you want to test (a class, a group of classes, the full end to end stack). For functional tests, try and pick a group that is at the same "level", or that achieve an isolated unit of work that makes sense as a standalone function.
  2. Draw a mental box around the classes that will be in the test. Everything inside that box should be able to be completely refactored (methods renamed, classes renamed, code moved around) without breaking this test. Only mock or stub or test calls to things at the edges of the box.
bethesque /
Last active May 2, 2016
A way to write a hipster batch microservice in Ruby
  1. Identify the steps in the high level process


    • Step 1: Download CSV files from box
    • Step 2: Convert CSV to JSON
    • Step 3: Upload JSON and CSV files to S3
  2. Create modules for each of those steps. In our use case, the top level process matches a pattern called "ETL" or "Extract, Transform, Load", so we used those names.

bethesque /
Created Feb 13, 2015
Using mocked interactions from pact unit tests for stubbing in integration tests

An idea: Set up an interaction for a unit test (using strict, exact matching), but specify that it can be used for stubbing in a later test, and specify the route that it should be matched against (with optional tags?). The Mock Server would write these interactions to a separate file, or add metadata to them in the normal pact file. Then, during an integration test, interactions can be loaded and will act as stubs using "type based" matching (something_like).

This means that our stubs will be verified as well as our mocks.

bethesque / example.rb
Last active Aug 29, 2015
I don't know what the name of this pattern is but I've been using it a lot recently and I like it
View example.rb
class Action
def parameter
def initialize parameter
@parameter = parameter
bethesque / reform.rb
Last active Aug 29, 2015
Reform writeable:false behaviour not the same as virtual: true
View reform.rb
require 'minitest/autorun'
require 'date'
require 'reform' # 1.2.2
Person =
class DateForm < Reform::Form
property :day
property :month
property :year
bethesque / spike.rb
Created Nov 27, 2014
Modifying headers before replaying request using Pact
View spike.rb
class ProxyApp
def initialize real_app
@real_app = real_app
def call env'HTTP_AUTHORIZATION' => '12345'))
bethesque / example.rb
Created Nov 26, 2014
Using Representable to convert one hash to another hash without having to create intermediate classes
View example.rb
require 'representable'
require 'representable/json'
require 'ostruct'
require 'json'
require 'hashie'
json = {
person: {
name: 'Beth',
surname: 'Someone'
You can’t perform that action at this time.