Sinatra Rspec - testing that a view has rendered

Viewed 646

I am writing tests for a Sinatra app that takes input from an API via a gem. Once I have the API response I need to test that the template has correctly rendered. The response of the API will be the HTML of the page that I am loading.

My first instinct was to write a test that looks like this:

describe 'the root path'
  it 'should render the index view' do
    get '/'

    expect(last_response).to render_template(:index)
  end 
end

Unfortunately when I try this I get the following error: undefined method `render_template'

I was wondering if anyone has encountered this problem - it seems like it should be an easy fix, but I can't seem to find any documentation to help with it.

2 Answers
Related