Hey Guys,
This is probably not specific to Rails, but I’m kinda hoping someone
already faced this error, it’s been hours trying to debug the issue, but
I just can’t figure out why it’s happening
So the application I’m developing is on Rails 3.1 using the 3-1-stable
branch, up-to-date, and I’m using latest version of all the Gems listed
in the Gemfile below…
When I run guard with the guard-spork portion commented, everything
works just fine, however, if I enable spork, I get the following error
on the second time the tests run, that’s right, the first time the tests
run like usual but If I save/touch any of the test file, rspec gets
invoked and the following error is shown (all the tests fail of course).
Any hints?
Regards,
Wael
Failure/Error: Unable to find matching line from backtrace
PGError:
no connection to the server
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in
exec' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in
block in clear_cache!’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:271:in
each_value' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:271:in
clear_cache!’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:286:in
reconnect!' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:167:in
verify!’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in
block in checkout_and_verify' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activesupport/lib/active_support/callbacks.rb:390:in
_run_checkout_callbacks’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activesupport/lib/active_support/callbacks.rb:81:in
run_callbacks' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:314:in
checkout_and_verify’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:310:in
checkout_existing_connection' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:253:in
block (2 levels) in checkout’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:251:in
loop' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:251:in
block in checkout’
#
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in
mon_synchronize' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:250:in
checkout’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:152:in
connection' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:389:in
retrieve_connection’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:107:in
retrieve_connection' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in
connection’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/fixtures.rb:463:in
create_fixtures' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/fixtures.rb:928:in
load_fixtures’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/fixtures.rb:894:in
setup_fixtures' # /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rspec-rails-2.6.1/lib/rspec/rails/adapters.rb:11:in
block (2 levels) in setup’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in
instance_eval' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in
run_in’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in
block in run_all' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in
each’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in
run_all' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:116:in
run_hook’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in
block in eval_before_eachs' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in
each’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in
eval_before_eachs' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:145:in
run_before_each’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:47:in
block in run' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:107:in
with_around_hooks’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:45:in
run' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:294:in
block in run_examples’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in
map' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in
run_examples’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:262:in
run' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in
block in run’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in
map' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in
run’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in
block in run' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in
map’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in
run' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in
block (2 levels) in run’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in
map' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in
block in run’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/reporter.rb:12:in
report' # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:21:in
run’
#
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/monkey/spork/test_framework/rspec.rb:5:in
run_tests' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/run_strategy/forking.rb:13:in
block in run’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/forker.rb:21:in
block in initialize' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/forker.rb:18:in
fork’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/forker.rb:18:in
initialize' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/run_strategy/forking.rb:9:in
new’
#
/usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/run_strategy/forking.rb:9:in
run' # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/server.rb:48:in
run’
#
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1558:in
perform_without_block' # /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1518:in
perform’
#
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1592:in
block (2 levels) in main_loop' # /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in
loop’
#
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in
`block in main_loop’
Finished in 0.13198 seconds
13 examples, 13 failures
Gemfile:
source ‘http://rubygems.org’
gem ‘rails’, ‘3.1.0.beta1’
Bundle edge Rails instead:
gem ‘rails’, :git => ‘git://github.com/rails/rails.git’, :branch =>
‘3-1-stable’
Databases, choose whichever you are using
gem ‘pg’ # PostgreSQL
gem ‘sqlite3’ # Sqlite3
gem ‘mysql2’ # MySQL
Squeel (The new MetaWhere)
gem ‘squeel’
gem ‘squeel’, :git => ‘git://github.com/ernie/squeel.git’
Forigner used to add add_foreign_key helper in the migrations
gem ‘foreigner’
Carrierwave is used to upload files from a form
gem ‘carrierwave’
Coffee script dependency
gem ‘therubyracer’, :require => false
Asset template engines
gem ‘sass-rails’
gem ‘coffee-script’
gem ‘uglifier’
gem ‘haml-rails’
gem ‘rdiscount’
gem ‘jquery-rails’
Pjax Rails
gem ‘pjax_rails’, :git => ‘git://github.com/rails/pjax_rails.git’
Devise
gem ‘devise’, :git => ‘git://github.com/plataformatec/devise.git’
Switch user
gem ‘switch_user’
CanCan
gem ‘cancan’
Nokogiri
gem ‘nokogiri’
Decent Exposure, cleanup the controller
gem ‘decent_exposure’
Use unicorn as the web server
gem ‘unicorn’
Deploy with Capistrano
gem ‘capistrano’
To use debugger
gem ‘ruby-debug19’, :require => ‘ruby-debug’
group :development, :test do
gem ‘rspec-rails’, ‘>= 2.6.1’
Mac OSX Specific gems
gem ‘rb-fsevent’, :require => false
gem ‘growl’, :require => false
Linux Specific gems
gem ‘rb-inotify’, :require => false
gem ‘libnotify’, :require => false
Guard
gem ‘guard’
gem ‘guard-bundler’
gem ‘guard-livereload’
gem ‘guard-spork’
Faker used to generate data in the developement environment
gem ‘faker19’
Populator
gem ‘populator’
Metrics
gem ‘metrical’
Powify and Powder
gem ‘powify’
gem ‘powder’
Required for ‘rake doc:guides’
gem ‘RedCloth’
Pretty printed test output
gem ‘turn’, :require => false
gem ‘webrat’
gem ‘factory_girl_rails’
gem ‘guard-rspec’
gem ‘spork’, :git => “git://github.com/timcharper/spork.git”
gem ‘capybara’
gem ‘database_cleaner’
gem ‘launchy’
end
Guardfile
A sample Guardfile
More info at GitHub - guard/guard: Guard is a command line tool to easily handle events on file system modifications.
group ‘frontend’ do
guard ‘livereload’ do
watch(%r{app/.+.(erb|haml)})
watch(%r{app/helpers/.+.rb})
watch(%r{config/locales/.+.yml})
watch(%r{app/assets/(images|javascripts|stylesheets)/.+})
end
end
group ‘backend’ do
guard ‘bundler’ do
watch(‘Gemfile’)
# Uncomment next line if Gemfile contain `gemspec’ command
# watch(/^.+.gemspec/)
end
guard ‘spork’ do
watch(‘config/application.rb’)
watch(‘config/environment.rb’)
watch(%r{^config/environments/.+.rb$})
watch(%r{^config/initializers/.+.rb$})
watch(‘spec/spec_helper.rb’)
end
guard ‘rspec’, :version => 2, :cli => “–drb” do
watch(‘spec/spec_helper.rb’) { “spec” }
watch(%r{^spec/support/(.+).rb}) { “spec” }
watch(‘config/routes.rb’) {
[“spec/routing”, “spec/requests”] }
watch(‘app/controllers/application_controller.rb’) {
“spec/controllers” }
watch(%r{^spec/.+_spec.rb})
watch(%r{^app/(.+).rb}) { |m|
“spec/#{m[1]}_spec.rb” }
watch(%r{^lib/(.+).rb}) { |m|
"spec/lib/#{m[1]}spec.rb" }
watch(%r{^app/controllers/(.+)(controller).rb}) { |m|
[“spec/routing/#{m[1]}routing_spec.rb",
"spec/#{m[2]}s/#{m[1]}#{m[2]}_spec.rb”,
“spec/acceptance/#{m[1]}_spec.rb”] }
watch(%r{^spec/.+_spec.rb})
watch(%r{^spec/.+factories.rb}) { “spec” }
end
end
spec_helper.rb
require ‘rubygems’
require ‘spork’
Spork.prefork do
Loading more in this block will cause your tests to run faster.
However,
if you change any configuration or code from libraries loaded here,
you’ll
need to restart spork for it take effect.
This file is copied to spec/ when you run 'rails generate
rspec:install’
ENV[“RAILS_ENV”] ||= ‘test’
require File.expand_path(“…/…/config/environment”, FILE)
require ‘rspec/rails’
require ‘faker’
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the
appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord
fixtures
config.fixture_path = “#{::Rails.root}/spec/fixtures”
# If you're not using ActiveRecord, or you'd prefer not to run each
of your
# examples within a transaction, remove the following line or assign
false
# instead of true.
config.use_transactional_fixtures = true
end
end
Spork.each_run do
This code will be run each time you run your specs.
Requires supporting ruby files with custom matchers and macros, etc,
in spec/support/ and its subdirectories.
Dir[Rails.root.join(“spec/support/**/*.rb”)].each {|f| require f}
end