A煤n no tienes acceso a esta clase

Crea una cuenta y contin煤a viendo este curso

Casos de uso para nuestra aplicaci贸n

7/33
Recursos

Aportes 3

Preguntas 0

Ordenar por:

驴Quieres ver m谩s aportes, preguntas y respuestas de la comunidad? Crea una cuenta o inicia sesi贸n.

Me agrada mucho esta metodolog铆a de explicar que se har谩 antes de hacer algo!!!

Hola al implementar el paso a paso que hay en el curso puedes notar que la documentaci贸n de git hub ha cambiado un poco pero no afecta mucho a este error:

bundle exec rspec

An error occurred while loading ./spec/requests/health_spec.rb.
Failure/Error:
  Shoulda::Matchers.configure do | config |
    config.integrate do |with|
      with.test_framework :rspec
  
      with.library :active_record
      with.library :active_model
      with.library :action_controller
  
      with.library :rails
    end

NameError:
  uninitialized constant Shoulda
# ./spec/rails_helper.rb:12:in `<top (required)>'
# ./spec/requests/health_spec.rb:1:in `require'
# ./spec/requests/health_spec.rb:1:in `<top (required)>'
# ------------------
# --- Caused by: ---
# NameError:
#   uninitialized constant Shoulda
#   ./spec/rails_helper.rb:12:in `<top (required)>'
No examples found.


Finished in 0.01366 seconds (files took 1.22 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

Lo que realmente afecta es no incluir estas tres librerias:

# Add additional requires below this line. Rails is not loaded until this point!
require 'database_cleaner'
require 'shoulda-matchers'
require 'factory_bot_rails'

en el archivos /spec/rails.helper.rb lo cual no se menciona en los paso a paso del video, una vez la incluyas y si tenias el error que te relaciono arriba posiblemente al ejecutar este comando: bundle exec rspec

la felicidad llegue a ti con un mensaje como este:

Failures:

  1) Health Endpoint GET health should return OK
     Failure/Error: before { get 'health'}
     
     URI::InvalidURIError:
       bad URI(is not URI?): "http://www.example.com:80health"
     # ./spec/requests/health_spec.rb:7:in `block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:65:in `block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:64:in `block (2 levels) in <top (required)>'

  2) Health Endpoint GET health should return status code 200
     Failure/Error: before { get 'health'}
     
     URI::InvalidURIError:
       bad URI(is not URI?): "http://www.example.com:80health"
     # ./spec/requests/health_spec.rb:7:in `block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:65:in `block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:64:in `block (2 levels) in <top (required)>'

Finished in 0.48693 seconds (files took 4.13 seconds to load)
2 examples, 2 failures

Failed examples:

rspec ./spec/requests/health_spec.rb:9 # Health Endpoint GET health should return OK
rspec ./spec/requests/health_spec.rb:15 # Health Endpoint GET health should return status code 200

Excelente!