Skip to content

Instantly share code, notes, and snippets.

def should_be_a_subset(superset, records_selected_by_scope, &condition)
flunk "Your superset is empty" if superset.empty?
flunk "Your scope did not select any records" if records_selected_by_scope.empty?
records_selected_by_block, records_excluded_by_block = superset.partition(&condition)
flunk "Your test condition did not select any records" if records_selected_by_block.empty?
flunk "Your test condition did not exclude any records" if records_excluded_by_block.empty?
records_selected_by_scope.map(&:id).should =~ records_selected_by_block.map(&:id)
end
RSpec::Matchers.define :be_an_ordering_of do |all_records, condition|
match do |ordered_records|
should_be_an_ordering(all_records, ordered_records, &condition)
end
end
def should_be_an_ordering(all_records, ordered_records, &condition)
flunk "There are no records" if all_records.empty?
flunk "Your ordered records are the same as the default ordering" if all_records == ordered_records
@seako
seako / README.md
Last active August 29, 2015 14:00 — forked from mbostock/.block
Color Flood III'
require 'benchmark'
class LocalLambda
def local_lambda
a_lambda = -> { 1 }
a_lambda.call
1
end
def nested_definition
@seako
seako / keybase.md
Created May 5, 2018 21:45
Keybase proof

Keybase proof

I hereby claim:

  • I am seako on github.
  • I am seako (https://keybase.io/seako) on keybase.
  • I have a public key ASAhRer4e4zz5ykwt06S9Huk2MyWE0QMRWWghwMOevxaLQo

To claim this, I am signing this object: