rspec-rails

rspec-rails
**************************************************

  Thank you for installing rspec-rails-2.5.0!

  This version of rspec-rails only works with versions of rails >= 3.0.0

  To configure your app to use rspec-rails, add a declaration to your Gemfile.
  If you are using Bundler's grouping feature in your Gemfile, be sure to include
  rspec-rails in the :development group as well as the :test group so that you
  can access its generators and rake tasks.

    group :development, :test do
      gem "rspec-rails", ">= 2.5.0" 
    end

  Be sure to run the following command in each of your Rails apps if you're
  upgrading:

    script/rails generate rspec:install

  Even if you've run it before, this ensures that you have the latest updates
  to spec/spec_helper.rb and any other support files.

  Beta versions of rspec-rails-2 installed files that are no longer being used,
  so please remove these files if you have them:

    lib/tasks/rspec.rake
    config/initializers/rspec_generator.rb

  Lastly, be sure to look at Upgrade.markdown to see what might have changed
  since the last release.
...

Configuración de su aplicación para que use rspec

[gomix@fricky FDCOS]$ script/generate rspec
      exists  lib/tasks
      create  lib/tasks/rspec.rake
      create  script/autospec
      create  script/spec
      exists  spec
      create  spec/rcov.opts
      create  spec/spec.opts
      create  spec/spec_helper.rb
  • lib/tasks/rspec.rake: Agrega un conjunto de tareas rake spec a su aplicación. Estas tareas ofrecen varias formas de ejecutar sus specs. Ejecute rake -T spec para listarlas y averiguar un poco sobre ellas.
$ rake -T spec
(in /home/gomix/Ruby/miniproyectos/FDCOS)
rake doc:plugins:rspec            # Generate documentation for the rspec plugin
rake doc:plugins:rspec-rails      # Generate documentation for the rspec-rails plugin
rake gems:refresh_specs           # Regenerate gem specifications in correct format.
rake spec                         # Run all specs in spec directory (excluding plugin specs)
rake spec:clobber_rcov            # Remove rcov products for rcov
rake spec:controllers             # Run the code examples in spec/controllers
rake spec:db:fixtures:load        # Load fixtures (from spec/fixtures) into the current environment's database.
rake spec:doc                     # Print Specdoc for all specs (excluding plugin specs)
rake spec:helpers                 # Run the code examples in spec/helpers
rake spec:integration             # Run the code examples in spec/integration
rake spec:lib                     # Run the code examples in spec/lib
rake spec:models                  # Run the code examples in spec/models
rake spec:plugin_doc              # Print Specdoc for all plugin examples
rake spec:plugins                 # Run the code examples in vendor/plugins (except RSpec's own)
rake spec:plugins:rspec_on_rails  # Runs the examples for rspec_on_rails
rake spec:rcov                    # Run all specs in spec directory with RCov (excluding plugin specs)
rake spec:views                   # Run the code examples in spec/views
  • script/autospec: Es un comando que provee la integración con autotest en su proyecto Rails.
  • script/spec: Es un comando para ejecutar los archivos spec directamente con la versión de rspec que la aplicación Rails ha sido configurada, system-wide rspec
    gem, gem rspec local en vendor/gems, o rspec instalado en vendor/plugins.
  • script/spec_server: Una comando que hace corre el servidor para ejecutar los specs más rápidamente en su aplicación Rails.
  • spec: Es el directorio donde usted colocará los specs para su aplicación Rails.
  • spec/rcov.opts: Agregue las opciones que usted desee que rcov utilice cuando ejecute cualquiera de las tareas rake spec con rcov, ejemplo rake
    spec:rcov.
  • spec/spec.opts: Agregue las opciones que usted desee que rspec utilice cuando ejecute cualquier de las tareas rake spec.
  • spec/spec_helper.rb: Este archivo se usa para carga y configurar rspec. También es el sitio donde usted hará sus require y configurará cualquier helper adicional o herramientas que su proyecto utilice cuando corra los specs.

scaffold modelo

[gomix@fricky FDCOS]$ ruby script/generate rspec_scaffold Odp
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      exists  app/views/odps
      exists  app/views/layouts/
      exists  public/stylesheets/
      create  spec/controllers/
      create  spec/routing/
      create  spec/models/
      create  spec/helpers/
      create  spec/fixtures/
      create  spec/views/odps
      create  spec/integration/
      create  app/views/layouts/odps.html.erb
      create  public/stylesheets/scaffold.css
      create  spec/routing/odps_routing_spec.rb
      create  spec/controllers/odps_controller_spec.rb
   identical  app/controllers/odps_controller.rb
      create  spec/helpers/odps_helper_spec.rb
      create  app/helpers/odps_helper.rb
overwrite app/views/odps/index.html.erb? (enter "h" for help) [Ynaqdh] Y
       force  app/views/odps/index.html.erb
overwrite app/views/odps/show.html.erb? (enter "h" for help) [Ynaqdh] Y
       force  app/views/odps/show.html.erb
overwrite app/views/odps/new.html.erb? (enter "h" for help) [Ynaqdh] Y
       force  app/views/odps/new.html.erb
overwrite app/views/odps/edit.html.erb? (enter "h" for help) [Ynaqdh] Y
       force  app/views/odps/edit.html.erb
overwrite app/models/odp.rb? (enter "h" for help) [Ynaqdh] Y
       force  app/models/odp.rb
      create  spec/fixtures/odps.yml
      create  spec/models/odp_spec.rb
      create  spec/views/odps/edit.html.erb_spec.rb
      create  spec/views/odps/index.html.erb_spec.rb
      create  spec/views/odps/new.html.erb_spec.rb
      create  spec/views/odps/show.html.erb_spec.rb
      create  spec/integration/odps_spec.rb
      exists  db/migrate
Another migration is already named create_odps: db/migrate/20110303213416_create_odps.rb

Si el modelo no existe previamente:

[gomix@fricky FDCOS]$ ruby script/generate rspec_scaffold Odp
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/odps
      exists  app/views/layouts/
      exists  public/stylesheets/
      create  spec/controllers/
      create  spec/routing/
      create  spec/models/
      create  spec/helpers/
      create  spec/fixtures/
      create  spec/views/odps
      create  spec/integration/
      create  app/views/layouts/odps.html.erb
      create  public/stylesheets/scaffold.css
      create  spec/routing/odps_routing_spec.rb
      create  spec/controllers/odps_controller_spec.rb
      create  app/controllers/odps_controller.rb
      create  spec/helpers/odps_helper_spec.rb
      create  app/helpers/odps_helper.rb
      create  app/views/odps/index.html.erb
      create  app/views/odps/show.html.erb
      create  app/views/odps/new.html.erb
      create  app/views/odps/edit.html.erb
      create  app/models/odp.rb
      create  spec/fixtures/odps.yml
      create  spec/models/odp_spec.rb
      create  spec/views/odps/edit.html.erb_spec.rb
      create  spec/views/odps/index.html.erb_spec.rb
      create  spec/views/odps/new.html.erb_spec.rb
      create  spec/views/odps/show.html.erb_spec.rb
      create  spec/integration/odps_spec.rb
      create  db/migrate
      create  db/migrate/20110304160416_create_odps.rb
       route  map.resources :odps