jeudi 11 janvier 2018

Rspec expect view file by name

I would like to know if Rspec has any expect to check the render view file by name. This is my situation:

I have a method with if and else conditions, and each condition render a specific view page.

def my_method
  if condition01
    'view_file_01'
  elsif condition02
    'view_file_02'
  else
    'view_file_03'
  end
end

At my test I doing this:

it 'should get "view_file_01"' do       
  # setup condition for view_file_01
  get :my_method
  expect(response).to have_http_status(200)
end

The problem is, I am just checking if the response is ok, but this could happen for any page, so I would like to know if Rspec has some expect like:

expect(current.view.name).to eq('my_method/view_file_01.erb')

Aucun commentaire:

Enregistrer un commentaire