This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cucumber' | |
while(f = File.read('features/run').strip) do | |
Process.detach(Process.fork { | |
::ActiveRecord::Base.connection.reconnect!; | |
::Cucumber::Cli::Main.new([f], $stdout, $stderr).execute! | |
}).join | |
puts 'done!!' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bundler' | |
require 'benchmark' | |
Benchmark.bm do |bm| | |
bm.report('Bundle.setup'.ljust(50)) do | |
Bundler.setup | |
end | |
bm.report('require "rails/all"'.ljust(50)) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler' | |
Bundler.setup | |
require 'active_record' | |
require 'erb' | |
ActiveRecord::Base.establish_connection( | |
YAML.load(ERB.new(File.read('config/dev_database.yml')).result)["test"] | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TypeColumn | |
def type_column(column_name, types = nil) | |
types ||= const_get(column_name.to_s.pluralize.upcase) | |
raise if types.blank? | |
validates_inclusion_of column_name, :in => types | |
types.each do |t| | |
scope t, where(column_name => t) | |
class_eval(%[def #{t}?; #{column_name} == #{t.dump}; end], __FILE__, __LINE__) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/Users/moro/opt/ruby192/bin/ruby | |
magicome = "# coding: #{Encoding.default_external.to_s.downcase}" | |
ARGV.each do |fname| | |
File.open(fname, 'r+:BINARY') do |src| | |
content = src.read | |
src.rewind | |
src.puts magicome | |
src.write content | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/Users/moro/opt/ruby192/bin/ruby | |
excludes = ['db/schema.rb'] | |
invalids = `git diff --name-only --cached`.each_line.inject([]) do |r, f| | |
f.strip! | |
if (f =~ /\.rb\Z/) && !excludes.include?(f) && (File.open(f, "r", &:gets) !~ /\A\#coding:/) | |
r << f | |
else | |
r | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyFilter | |
class << self | |
def method_missing(m_name, *ignore) | |
new(m_name) | |
end | |
end | |
def initialize(bar) | |
@bar = bar | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snippet describe | |
abbr describe DESC do before do end end | |
describe '${1:DESC}' do | |
before do | |
${2} | |
end | |
end | |
snippet RS::M | |
abbr RSpec::Matcher.define |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ImportUtil | |
module ClassMethods | |
def inside_import? | |
Thread.current[:inside_import] | |
end | |
def step_into_import | |
t = Thread.current[:inside_import] | |
begin | |
Thread.current[:inside_import] = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
require 'active_support/core_ext/array' | |
describe do | |
def parent_subject | |
self.class.ancestors[1].instance_variable_get('@explicit_subject_block').call | |
end | |
subject { [:one, :two, :three] } |