Skip to content

Instantly share code, notes, and snippets.

@d3r1v3d
d3r1v3d / PropertyTests.scala
Created June 3, 2020 18:50 — forked from davidallsopp/PropertyTests.scala
Examples of writing mixed unit/property-based (ScalaTest with ScalaCheck) tests. Includes tables and generators as well as 'traditional' tests.
/**
* Examples of writing mixed unit/property-based (ScalaCheck) tests.
*
* Includes tables and generators as well as 'traditional' tests.
*
* @see http://www.scalatest.org/user_guide/selecting_a_style
* @see http://www.scalatest.org/user_guide/property_based_testing
*/
import org.scalatest._
@d3r1v3d
d3r1v3d / keybase.md
Created September 1, 2019 20:32
Proof of identity for Keybase

Keybase proof

I hereby claim:

  • I am d3r1v3d on github.
  • I am d3r1v3d (https://keybase.io/d3r1v3d) on keybase.
  • I have a public key ASDErgTstlmf6_akJPatkjJzbMrjVK4u4kuglXM-ehgS3go

To claim this, I am signing this object:

module CustomColumnTypes
def double(*args)
args.last[:limit] = 53 if args.last.is_a? Hash
float *args
end
end
module ActiveRecord
module ConnectionAdapters
class Table
class CarsController < ApplicationController
# ...
# GET /cars/1
def show
@car = Car.find(params[:id])
# ...
end
# GET /cars/1/edit
module EnumSupport
def enum(name, values)
const_name = name.to_s.pluralize.upcase
self.class_eval "
#{const_name} = %w{#{values.join(' ')}}.map{ |val| val.to_sym }
validates :#{name}, :presence => true,
:inclusion => {:in => #{const_name}, :message => self.bad_enum_message(#{const_name})}
def #{name}
read_attribute(:#{name}).to_sym
end