ruby-on-rails rspec spork

ruby on rails - Obtención de un error constante sin inicializar con RSpec. No tengo idea de lo que lo está causando.



ruby-on-rails spork (4)

Es posible que encuentre este problema si está tratando de usar rspec-rails en un proyecto que no es de rails. En ese caso, el uso de require "rails/all" no es una opción porque requeriría cosas de ActiveRecord dejándote con:

ActiveRecord::ConnectionNotEstablished: No connection pool with ''primary'' found.

En su lugar, puede solucionar este problema con:

require "action_controller/railtie"

Estoy usando RSpec para las pruebas y cuando salí del trabajo el viernes por la tarde, mis pruebas estaban pasando. Pero cuando fui a casa y sincronicé mi repositorio, las pruebas fallaron en mi computadora portátil. Ahora de vuelta en el trabajo, las pruebas siguen fallando. No crea que es mi código, ya que la ejecución de rspec devuelve un error y spork ni siquiera se inicia. Cuando intento iniciar Spork, aparece el siguiente mensaje de error:

Using RSpec Loading Spork.prefork block... uninitialized constant ActionView::Template::Handlers::ERB::ENCODING_FLAG (NameError) /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.2.1/lib/rspec/core/backward_compatibility.rb:20:in `const_missing'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:85:in `<class:ERB>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:70:in `<module:Handlers>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:28:in `<class:Template>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:27:in `<module:ActionView>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:6:in `<top (required)>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers.rb:10:in `extended'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template.rb:99:in `extend'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template.rb:99:in `<class:Template>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template.rb:8:in `<module:ActionView>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template.rb:6:in `<top (required)>'' <internal:lib/rubygems/custom_require>:29:in `require'' <internal:lib/rubygems/custom_require>:29:in `require'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/resolver.rb:3:in `<top (required)>'' <internal:lib/rubygems/custom_require>:29:in `require'' <internal:lib/rubygems/custom_require>:29:in `require'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/actionpack-3.0.3/lib/action_view/testing/resolvers.rb:1:in `<top (required)>'' <internal:lib/rubygems/custom_require>:29:in `require'' <internal:lib/rubygems/custom_require>:29:in `require'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-rails-2.2.1/lib/rspec/rails/view_rendering.rb:1:in `<top (required)>'' <internal:lib/rubygems/custom_require>:29:in `require'' <internal:lib/rubygems/custom_require>:29:in `require'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-rails-2.2.1/lib/rspec/rails.rb:9:in `<top (required)>'' <internal:lib/rubygems/custom_require>:33:in `require'' <internal:lib/rubygems/custom_require>:33:in `rescue in require'' <internal:lib/rubygems/custom_require>:29:in `require'' /home/jeff/Projects/Rails/vahsfbhistory/spec/spec_helper.rb:10:in `block in <top (required)>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork.rb:23:in `prefork'' /home/jeff/Projects/Rails/vahsfbhistory/spec/spec_helper.rb:5:in `<top (required)>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork/test_framework.rb:138:in `load'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork/test_framework.rb:138:in `block (2 levels) in preload'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork/app_framework.rb:64:in `preload'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork/test_framework.rb:134:in `block in preload'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork.rb:67:in `exec_prefork'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork/test_framework.rb:120:in `preload'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork/run_strategy/forking.rb:25:in `preload'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork/runner.rb:74:in `run'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/lib/spork/runner.rb:9:in `run'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/spork-0.8.4/bin/spork:10:in `<top (required)>'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/bin/spork:19:in `load'' /home/jeff/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/bin/spork:19:in `<main>''

Alguien sabe que podría estar causando esto?


Me encontré con este problema. En el spec_helper.rb intente reemplazar:

require "rails"

con

require "rails/all"

Trabajó en mi situación.


Necesita inicializar el entorno, agregue esta línea a spec_helper.rb :

require File.expand_path("../../config/environment", __FILE__)


Si no es una aplicación de Rails y no desea incluir todos los Rails, agregue esto a su spec_helper.rb :

require ''action_view''