Skip to content

Instantly share code, notes, and snippets.

@deepfryed
deepfryed / Gemfile
Created January 16, 2013 10:32 — forked from ronny/Gemfile
source :rubygems
# Turbolinks and jQuery.turbolinks without Rails dependencies
gem 'turbolinks', :git => 'git://github.com/ronny/turbolinks.git', :branch => 'lite'
gem 'jquery-turbolinks', :git => 'git://github.com/ronny/jquery.turbolinks.git', :branch => 'lite'
@deepfryed
deepfryed / adapter_test.rb
Created July 14, 2012 22:00 — forked from jodosha/adapter_test.rb
Quick and dirty porting of RSpec's shared examples to MiniTest.
require 'test_helper'
shared_examples_for 'An Adapter' do
describe '#read' do
before do
@adapter.write(@key = 'whiskey', @value = "Jameson's")
end
it 'reads a given key' do
@adapter.read(@key).must_equal(@value)
@deepfryed
deepfryed / test.rb
Created January 12, 2012 03:44 — forked from tenderlove/test.rb
# encoding: utf-8
require 'rubygems'
require 'benchmark/ips'
require 'set'
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].to_set
def original value
if value.is_a?(String) && value.empty?
# Add pessmistic locking support. Make sure you're inside a transaction.
# resource = MyResource.get(24)
# resource.lock! # write lock (FOR UPDATE)
#
# TODO:
# resource = MyResource.get_with_lock!(:write, 24)
# resource = MyResource.get_with_lock!(:read, 24)
# MyResource.all(:lock => :write)
module DataMapper
require 'rack'
require 'thin'
module Rack
module Test
class App
# Attempt to run a Rack app server instance in the same process as the a
# 'work' block. Came about because you can't see an unsaved DB transaction
# inside the Rack app if it happens in another process.
#