Skip to content

Instantly share code, notes, and snippets.

💭
Intermittently coding

Beth Skurrie bethesque

💭
Intermittently coding
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
bethesque / gist:9385794
Created Mar 6, 2014
Naming conventions in Ruby
View gist:9385794
ClassNamesAreLikeThis
ModuleNamesAreLinkThis
def method_names_are_like_this
local_variable_names_are_like_this
@instance_variable_names_are_like_this
CONTSTANT_NAMES_ARE_LIKE_THIS
module Things
class UserThing
@bethesque
bethesque / gist:69ae590e8312523e5337
Last active Aug 29, 2015
Thoughts on verifying that mocked models are actually valid
View gist:69ae590e8312523e5337

It's about ensuring the model used to stub client responses can actually be produced by the response you expect. Imagine your client returns a model like so:

class MyModel
   attr_reader :timestamp
   
   def initialize attrs
      @timestamp = attr[:timestamp]
   end
end
@bethesque
bethesque / preload-interactions.rb
Last active Aug 29, 2015
Server with preloaded interactions
View preload-interactions.rb
# $ pact service -p 8080
# (new window)
# $ ruby preload-interactions.rb
# $ curl localhost:8080/path_one #Yay all good!
# $ curl localhost:8080/path_two #Boo... which response do we want???
require 'json'
require 'net/http'
require 'pact/consumer/consumer_contract_builder'
require 'pact/consumer_contract'
@bethesque
bethesque / idea.rb
Last active Aug 29, 2015
Using pact for Capybara tests and unit tests
View idea.rb
class InternalProviderClient
def thing
#get a thing from the internal provider
end
end
# pact_helper
Pact.configure do | config |
config.pactfile_write_mode = :update
@bethesque
bethesque / 1.md
Last active Aug 29, 2015
Idea for FixturePact
View 1.md

Pact is great for HTTP microservices that communicate directly with each other, but many services use an intermediate system that acts as a pipe (eg. a queue, S3 bucket). The agreement about the format of the message is really between the two ends of the chain, not between the links immediatly adjacent.

The pact concept should be able to be applied to non-http services. The code below is an attempt to come up with a DSL for a new pact library that uses the same pact matching concepts, but does not constrain the communication protocol.

Thoughts/improvements appreciated, but remember Gists do not send notifications when you post a comment :|

@bethesque
bethesque / documentation.md
Last active Aug 29, 2015
A quick start guide to Webmachine
View documentation.md

GET

  • Override resource_exists?, content_types_provided, allowed_methods, and implement the method to render the resource.
class OrderResource < Webmachine::Resource
  def allowed_methods
    ["GET"]
  end
  
  def content_types_provided
@bethesque
bethesque / example.rb
Created Oct 9, 2014
How to do a multipart updatable date with Reform
View example.rb
require 'date'
class Applicant
attr_accessor :date
end
applicant = Applicant.new
applicant.date = Date.new(2014, 10, 13)
require 'reform'
@bethesque
bethesque / document.rb
Last active Aug 29, 2015
Pact Broker document
View document.rb
PactBroker::Client::PacticipantDocumentationTask.new do | pacticipant |
pacticipant.repository git: 'git@github.com/bethesque/some-consumer'
pacticipant.doc 'http://github.com/bethesque/some-consumer'
end
@bethesque
bethesque / echoHttpRequest.js
Last active Aug 29, 2015 — forked from Marak/echoHttpRequest.js
Echo HTTP requests
View echoHttpRequest.js
module['exports'] = function echoHttp (hook) {
hook.debug("Debug messages are sent to the debug console");
hook.debug(hook.params);
hook.debug(hook.req.path);
hook.debug(hook.req.method);
You can’t perform that action at this time.