Skip to content

Instantly share code, notes, and snippets.

View gabetax's full-sized avatar

Gabe Martin-Dempesy gabetax

  • Zendesk
  • San Francisco
  • 11:14 (UTC -07:00)
View GitHub Profile
@gabetax
gabetax / rspec-expect-stand-alone-matchers.md
Last active December 20, 2015 16:18
rspec expect-syntax, stand-alone operators, and you

rspec expect syntax and stand-alone operator matches

I recently started a new project using rspec's newer (and soon to be default) expect syntax, and encountered this error:

expect(5).to == 5
ArgumentError: The expect syntax does not support operator matchers, so you must pass a matcher to `#to`

"Why'd they take out operator matches? I've grown quite accustomed to them!", I thought. Digging around, the source of this change started in pull request 119 citing issue 138 as one of the root causes. Here's what's actually happening:

module FeatureSpecMacros
module ExampleMethods
def successfully_visit(path)
visit path
successfully_on path
end
def successfully_on(path)
expect(page.current_path).to eq(path), "Expected: #{path} URL\nGot #{page.current_path}\n\nPage source:\n\n#{page.html}"
expect(page.status_code).to eq(200), "Expected: 200 status code\nGot #{page.status_code}\n\nPage source:\n\n#{page.html}"
@gabetax
gabetax / .ackrc
Created September 27, 2013 21:22
ack configuration for ruby / rails developers
--type-add=html:ext:html.erb
--type-add=css:ext:sass,less,scss
--type-add=js:ext:js.erb,coffee
--type-add=rspec:match:/_spec.rb$/
--ignore-dir=vendor
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=coverage
--ignore-dir=public/assets
--ignore-dir=spec/fixtures/cassettes
@gabetax
gabetax / _form.html.erb
Created October 11, 2013 16:51
Javascript Page Object Example
<% @body_data = {
page_object: 'PostForm',
rails_env: Rails.env,
post_max_length: Post.column_types['title'].limit
}
%>
@gabetax
gabetax / deploy.rb
Last active December 27, 2015 05:19 — forked from blackcoat/deploy.rb
# http://gembundler.com/deploying.html
require 'bundler/capistrano'
# http://guides.rubyonrails.org/asset_pipeline.html
load 'deploy/assets'
# http://beginrescueend.com/integration/capistrano/
# Also add rvm-capistrano to your Gemfile
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_type, :system # Copy the exact line. I really mean :system here
@gabetax
gabetax / hacky_each_else.rb
Created January 13, 2014 03:03
Hacky alternative to ruby not having each/else. Object#presence provided by active_support.
a = %w(a b c)
a.each do |i|
puts i
end.presence || puts("the array was empty")
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2008 sp1 (http://www.altova.com)-->
<tns:submission xsi:schemaLocation="aca ACASubmission.xsd" xmlns:tns="aca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<submissionYear>2011</submissionYear>
<business>
<businessType>Manufacturer</businessType>
<businessName>Business Name xyz</businessName>
</business>
<practitionerGroups>
<practitionerGroup>
@gabetax
gabetax / gist:b81d097792364d88eff0
Created April 16, 2015 22:30
SSL Certificate subject collision with alternate public keys / subject key identifiers
-----BEGIN CERTIFICATE-----
MIIFLjCCBBagAwIBAgIQAw6VKU2uwSwDzzGrWwJx1zANBgkqhkiG9w0BAQUFADBv
MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk
ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF
eHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFow
YjELMAkGA1UEBhMCVVMxITAfBgNVBAoTGE5ldHdvcmsgU29sdXRpb25zIEwuTC5D
LjEwMC4GA1UEAxMnTmV0d29yayBTb2x1dGlvbnMgQ2VydGlmaWNhdGUgQXV0aG9y
aXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5Lx+kjBtxtiOKwu8
Rs7gJ5be3vn6EtM8M3OzBC+8cYzln7YiYD5fXc4J/4IMG5pRUBomid3VYV0Z3BIP
LQqiQ10X0DSSIOpzzzgsBiYJenL3+lAy+MKT02miI85Bsczk1R820Yo6+Ixj4hRZ
@gabetax
gabetax / consul travis.yml
Created June 10, 2015 21:11
Consul support on Travis-CI
sudo: false
env:
global:
- CONSUL_VERSION=0.5.0
- CONSUL_DC=dev1
- CONSUL_DIR=$HOME/consul_$CONSUL_VERSION
before_script:
- 'if [[ ! -f $CONSUL_DIR/consul ]]; then (mkdir -p $CONSUL_DIR && cd $CONSUL_DIR && wget https://dl.bintray.com/mitchellh/consul/${CONSUL_VERSION}_linux_amd64.zip && unzip ${CONSUL_VERSION}_linux_amd64.zip); fi'
- $CONSUL_DIR/consul --version
- $CONSUL_DIR/consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul -dc=$CONSUL_DC &
@gabetax
gabetax / json_pluck.rb
Last active February 1, 2016 18:45
Pluck values out of JSON logs
#!/usr/bin/env ruby
require 'json'
# Usage:
# head production.log.json | ruby json_pluck.rb time,session,message
# colorize output when going to stdout or if explicitly requested (e.g. `| less -r`)
color = $stdout.tty?
color = true if ARGV.first == '-c' && ARGV.shift