Skip to content

Instantly share code, notes, and snippets.

View dscataglini's full-sized avatar

Diego Scataglini dscataglini

View GitHub Profile
package com.junivi.lang;
public interface Block {
}
require 'rubygems'
require 'andand'
require 'benchmark'
include Benchmark
t = 1_000_000
class A
attr_accessor :foo
end
require 'rubygems'
require 'ruby_parser'
require 'parse_tree'
require 'benchmark'
require 'pp'
include Benchmark
a = <<-EOF
class A
def foo
T = 1_000_000
ARGS = []
OBJECTS = []
ALPHA = ('a'..'z').to_a
require 'benchmark'
class G0
def bar(*args)
1
require 'benchmark'
include Benchmark
class A
def foo(a, b, c)
1
end
end
it 'resets the session' do should_receive(:reset_session); logout_killing_session! end
it 'kills my auth_token cookie' do should_receive(:kill_remember_cookie!); logout_killing_session! end
it 'nils the current user' do logout_killing_session!; current_user.should be_nil end
it 'kills :user_id session' do
session.stub!(:[]=)
session.should_receive(:[]=).with(:user_id, nil).at_least(:once)
logout_killing_session!
end
class A
attr_accessor :b
end
class B
end
def change_A x
x.b = 1
end
a = [1]
def bar x
x << 2
end
bar a
puts a
def foo(bar)
def bar.baz
1
@dscataglini
dscataglini / after.rb
Created July 31, 2009 18:15
The final ImageTagOptionParser class also take account of other logic that lived in a separate controller. Thus I now have one single place that knows all the rules for the options. Plus I now have an easy way to write a test for it. (this was done TDD bt
transformations = ImageTagOptionParser.new(options)
final_filepath = "#{prefix}/resources/images/#{file}?#{transformations}"
class ImageTagOptionParser
KEYS = %w{scale constrain crop cropresize}
attr_accessor :transform
def initialize(options = {})
options.reject!{|key, value| (key == "scale" && value.to_s == "100")}
first_valid_key = KEYS.find{|key| !options[key].blank?}
def create_user(user_options = {}, other_options = {})
base_options = { :login => 'unique', :email => 'unique@example.com',
:first_name => 'bob', :last_name => 'testerperson', :address => "123 Main St",
:city => "Santa Carla", :state => "CA", :zip => "95000", :subscription => "Tier 1",
:role => 'Member',
:password => 'quire69', :password_confirmation => 'quire69',:accept_terms => true }
post :create, {:user => (base_options.merge(user_options))}.merge(other_options)
end
it 'should set permissions on create' do