View example_test.rb
require 'minitest/autorun'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDOUT)
conn = { adapter: 'sqlite3', database: ':memory:' }
ActiveRecord::Base.establish_connection(conn)
class User < ActiveRecord::Base
connection.create_table :users, force: true do |t|
t.string :username
View test.rb
require 'active_support/all'
module SetupAndTeardown
extend ActiveSupport::Concern
included do
class_attribute :callbacks
self.callbacks = []
end
View gsoc_final.md
View rails_admin_error.log
Completed 500 Internal Server Error in 193ms (ActiveRecord: 3.7ms)
I18n::ArgumentError - Object must be a Date, DateTime or Time object. "" given.:
i18n (0.7.0) lib/i18n/backend/base.rb:53:in `localize'
i18n (0.7.0) lib/i18n.rb:247:in `localize'
rails_admin (0.8.1) lib/rails_admin/config/fields/types/datetime.rb:65:in `block in <class:Datetime>'
rails_admin (0.8.1) lib/rails_admin/config/configurable.rb:66:in `block in register_instance_option'
rails_admin (0.8.1) lib/rails_admin/config/fields/base.rb:113:in `block in <class:Base>'
rails_admin (0.8.1) lib/rails_admin/config/configurable.rb:66:in `block in register_instance_option'
rails_admin (0.8.1) lib/rails_admin/config/proxyable/proxy.rb:27:in `method_missing'
View minitest_assert.rb
require "rubocop"
module RuboCop
module Cop
module Lint
# This cop checks bad use of the Minitest `assert` method
#
# `assert` method's second argument is the error message when the
# first argument evals to false.
#
View initializer_instrumentation.rb
# Backport patch made on Rails 4.1 , to add instrumentation around the
# initializer load code. see https://github.com/rails/rails/pull/12859
# Remove this patch once we are on Rails 4.1+
Rails::Engine.class_eval do
if method_defined? :load_config_initializer
warn "[DEPRECATION] load_config_initializer patch can now be removed."
else
def load_config_initializer(initializer)
ActiveSupport::Notifications.instrument('load_config_initializer.railties', initializer: initializer) do
load(initializer)
View console.rb
[arthurnn@snowball ~]$ irb
irb(main):001:0> class Foo
irb(main):002:1> FOO = "foo"
irb(main):003:1> end
=> "foo"
irb(main):005:0> Foo.class_eval { BAR = "bar" }
=> "bar"
irb(main):006:0> BAR
=> "bar"
irb(main):007:0> FOO
View pg_test.rb
require 'pg'
class Context
attr_reader :connections
def initialize
@connections = {}
end
def connection
@connections.fetch(Process.pid) { @connections[Process.pid] = PG.connect( dbname: 'test' ) }
end
View pg_test.rb
require 'pg'
class Context
attr_reader :connections
def initialize
@connections = {}
end
def connection
@connections.fetch(Process.pid) { @connections[Process.pid] = PG.connect( dbname: 'test' ) }
end
View mysql_test.rb
require 'mysql2'
connection = Mysql2::Client.new(host: "127.0.0.1", port: 3306, username: "root", database: "test")
connection.automatic_close = false
p connection.query( "SELECT database();" ).to_a
fork { }
Process.wait
p connection.query( "SELECT database();" ).to_a