0

Trying to test my controller

static_pages_controller_spec.rb

require 'rails_helper'

    RSpec.describe StatigPagesController, type: :controller do
      it 'return home view' do
        get '/'
        expect(response).to render_template :home
      end

      it 'return about view' do
        get :about
        expect(response).to render_template :about
      end
    end

routes.rb

Rails.application.routes.draw do
  devise_for :users
  root 'static_pages#home'
  get '/about', to: 'static_pages#about'
end

and i get errors

   1) StatigPagesController return home view
        Failure/Error: get '/'

         ActionController::UrlGenerationError:
           No route matches {:action=>"/", :controller=>"statig_pages"}

  2) StatigPagesController return about view
     Failure/Error: get :about

     ActionController::UrlGenerationError:
       No route matches {:action=>"about", :controller=>"statig_pages"}

I wrote routes, What i'm do wrong?

1 Answer 1

2

You have a typo in your static_pages_controller_spec.rb

RSpec.describe StatigPagesController

Try:

RSpec.describe StaticPagesController
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.