Skip to content

Instantly share code, notes, and snippets.

@Sam-Serpoosh
Created June 4, 2012 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sam-Serpoosh/2869276 to your computer and use it in GitHub Desktop.
Save Sam-Serpoosh/2869276 to your computer and use it in GitHub Desktop.
error in blog sample app in @avdi's Objects on Rails with nulldb setup!!!
/home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:8:in `<module:ActiveRecord>': uninitialized constant ActiveRecord::ConnectionNotEstablished (NameError)
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:5:in `<top (required)>'
from /home/jesus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /home/jesus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:11:in `<top (required)>'
from /home/jesus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /home/jesus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-nulldb-adapter-0.2.1/lib/active_record/connection_adapters/nulldb_adapter.rb:4:in `<top (required)>'
from /home/jesus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /home/jesus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-nulldb-adapter-0.2.1/lib/nulldb_rspec.rb:1:in `<top (required)>'
from /home/jesus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /home/jesus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /home/jesus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /home/jesus/Rails Applications/blog_objects_rails/spec/spec_helper_lite.rb:2:in `<top (required)>'
from /home/jesus/Rails Applications/blog_objects_rails/spec/models/post_spec.rb:1:in `require_relative'
from /home/jesus/Rails Applications/blog_objects_rails/spec/models/post_spec.rb:1:in `<top (required)>'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `load'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `block in load_spec_files'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `map'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `load_spec_files'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.1/lib/rspec/core/command_line.rb:18:in `run'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:55:in `run_in_process'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:46:in `run'
from /home/jesus/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:10:in `block in autorun'
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development do
gem 'rspec-rails', '2.0.1'
end
group :test do
gem 'rspec', '2.0.1'
gem 'webrat', '0.7.1'
gem 'activerecord-nulldb-adapter', '0.2.1'
end
require_relative '../spec_helper_lite'
require_relative '../../app/models/post'
describe Post do
before do
setup_nulldb
...
end
after do
teardown_nulldb
end
...
end
require 'date'
require 'nulldb_rspec'
def require_folder(folder_name_in_app)
Dir[File.expand_path(File.dirname(__FILE__) + '/../app/' + folder_name_in_app + '/*.rb')].each { |file| require file }
end
require 'nulldb_rspec'
def setup_nulldb
schema_path = File.expand_path("../db/schema.rb/", File.dirname(__FILE__))
ActiveRecord::Base.establish_connection(:adapter => :nulldb, :schema => schema_path) # I tried without setting :schema option also I tried without this whole line
# also because of ActiveRecord::Base I required 'active_record' but I got no
# method error for nullify in NullDB module and also it became so slow because
# of requiring 'active_record' again
NullDB.nullify(:schema => schema_path)
end
def teardown_nulldb
NullDB.restore
end
def require_folder(folder_name_in_app)
Dir[File.expand_path(File.dirname(__FILE__) + '/../app/' + folder_name_in_app + '/*.rb')].each { |file| require file }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment