Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSpec fails testing [closed]

Indeed, it was a configuration issue. The spec/spec_helper.rd pointed to 'test' environment. I changed it to 'development' in order to make it refer to config/environments/development.rb

Best regards
Fred

I'm new to RoR, and following the RoR 3.2 Tutorial from Michael Hartl.

When it comes to execute the first testing (chap. 3.2.1), RSpec returns a hundred of errors starting with this one (and all looking the same more or less):

/home/fred/.rvm/gems/ruby-1.9.3-p0@ODQ/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:45:in
`resolve_hash_connection': database configuration does not specify
adapter (ActiveRecord::AdapterNotSpecified)

My DEV database is PostgreSQL and looks to work fine (migrations work well).

Can someone help me to understand what's wrong and solve it ?

Thanks.

Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'postgres-pr'
gem 'pg'

# gem for test scripts
group :development, :test do 
gem 'rspec-rails'
end

group :test do
  gem 'capybara', '1.1.2'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

database.yml:

# PostgreSQL 8.4
development:
  adapter: postgresql
  encoding: unicode
  database: ODQ_APP
  pool: 5

Environment:

Ruby version    1.9.3 (i686-linux)
RubyGems version    1.8.15
Rack version    1.4
Rails version   3.2.1
JavaScript Runtime  Node.js (V8)
Active Record version   3.2.1
Action Pack version 3.2.1
Active Resource version 3.2.1
Action Mailer version   3.2.1
Active Support version  3.2.1
Middleware  

ActionDispatch::Static
Rack::Lock
#<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0xa848460>
Rack::Runtime
Rack::MethodOverride
ActionDispatch::RequestId
Rails::Rack::Logger
ActionDispatch::ShowExceptions
ActionDispatch::DebugExceptions
ActionDispatch::RemoteIp
ActionDispatch::Reloader
ActionDispatch::Callbacks
ActiveRecord::ConnectionAdapters::ConnectionManagement
ActiveRecord::QueryCache
ActionDispatch::Cookies
ActionDispatch::Session::CookieStore
ActionDispatch::Flash
ActionDispatch::ParamsParser
ActionDispatch::Head
Rack::ConditionalGet
Rack::ETag
ActionDispatch::BestStandardsSupport

Application root    /home/fred/rails_projects/ODQ
Environment development
Database adapter    postgresql
Database schema version 20120503135705

Fred

like image 521
user1185081 Avatar asked May 30 '12 07:05

user1185081


1 Answers

you need to fix this

# PostgreSQL 8.4
development:
  adapter: postgresql
  encoding: unicode
  database: ODQ_APP
  pool: 5

and add test section like this

# PostgreSQL 8.4
test:
  adapter: postgresql
  encoding: unicode
  database: ODQ_APP_test
  pool: 5

also remember to create test db :) Rspec runs in "test" environment so he will be looking under test key from database.yml not development :)

like image 187
Jakub Oboza Avatar answered Sep 20 '22 02:09

Jakub Oboza