Skip to content

Instantly share code, notes, and snippets.

module Rubinius
class PrependedModule < IncludedModule
attr_reader :module
def initialize(mod, superclass)
@module = mod
@superclass = superclass
super(mod)
end
class UltimateProxy < BasicObject
def initialize(object)
delegate_everything_to(object)
end
private
def delegate_everything_to(object)
metaclass = class << self; self; end
metaclass.__send__(:define_method, :method_missing) do |message, *args|
class Genuine; end;
def access_granted?(object)
case object
when Genuine
true
else
false
end
end
genuine = Genuine.new
access_granted?(genuine) # => true
proxy = UltimateProxy.new(genuine)
proxy.class # => Genuine (despite this looks good...)
access_granted?(proxy) # => false (... we fail)
Genuine === genuine # => true
Genuine === proxy # => false
var zombie = require("zombie");
var assert = require("assert");
// Load the page from localhost
zombie.visit("http://localhost:3000/", function (err, browser, status) {
// Fill email, password and submit form
browser.
fill("session[email]", "[email protected]").
fill("session[password]", "123456").
require "activerecord"
ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => "test.sqlite"
class CategoriesMigration < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.string :name
t.string :type
end
qsort([Threshold | Tail]) ->
{ Left, Right } = split(Threshold, Tail),
qsort(Left) ++ [Threshold] ++ qsort(Right)
;
qsort([]) -> [].
describe Account do
contex "given an empty account" do
subject { Account.new(0) }
context "when I put money there" do
before { subject.put_money(120) }
its(:amount) { should == 120 }
it { should_not be_empty }