tests test spec run rails how describe ruby-on-rails ruby testing rspec

ruby-on-rails - spec - ruby on rails test



Error "No se carga ningĂșn archivo" al ejecutar Rspec (2)

Mac OS 10.4 rspec (1.1.11, 1.1.4, 1.1.3, 0.5.15) rspec-rails (1.1.11) rspec_generator (0.5.15) rails 2.2.2 ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0]

Creó un nuevo proyecto ...

$ rails myproject

Rspec instalado en el proyecto ...

$ script/generate rspec

Generado un recurso ...

$ script/generate rspec_scaffold myresource name:string description:text

Intenté ejecutar especificaciones ...

$ rake spec

Tengo este error:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'': no such file to load -- ./spec/models/../../vendor/generators/rspec/lib/rspec_on_rails (MissingSourceFile) from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in `require'' from ./spec/models/../spec_helper.rb:3 from ./spec/models/entry_spec.rb:1:in `require'' from ./spec/models/entry_spec.rb:1 from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in `load'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in `load_files'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in `each'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in `load_files'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in `run_examples'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in `run'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'': no such file to load -- /Users/ethan/project/project/spec/../vendor/generators/rspec/lib/rspec_on_rails (MissingSourceFile) from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in `require'' from /Users/ethan/project/project/spec/spec_helper.rb:3 from ./spec/controllers/entries_controller_spec.rb:1:in `require'' from ./spec/controllers/entries_controller_spec.rb:1 from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in `load'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in `load_files'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in `each'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in `load_files'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in `run_examples'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in `run'' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4

De hecho, no existe ese archivo ...

proveedor / generadores, ls:

rspec_controller rspec_model


Parece que funciona para mí. He instalado rspec-rails , ejecuté el generador de rspec y cuando doy

$ script/generate

Obtengo la lista de generadores:

Generadores instalados Rubygems: rspec, rspec_controller, rspec_model, rspec_scaffold Builtin: controller, integration_test, mailer, migración, modelo, observador, performance_test, plugin, resource, scaffold, session_migration

Después de generar el scaffold con rspec_scaffold, las especificaciones pasan. ¿Están los proveedores / generadores en su proyecto de rieles? Creo que deberías eliminarlos y usar los generadores de las gemas en su lugar.


Para rails3

Para obtener la lista

$ rails generate

Para generar spec_helper.rb

$ rails g rspec:install