Question

The rendered method in RSpec-rails' views examples is used for getting a rendered view template.

For example:

describe 'example/show.html.haml' do
  it 'displays \'ok!\'' do
    render
    rendered.should have_content('ok!')
  end
end

I'm in a difficulty in finding this method's roots. Where does it come from?

Thanks.

Debian GNU/Linux 6.0.1;

Ruby 1.9.2;

Ruby on Rails 3.1.0.rc4;

RSpec-rails 2.6.1.

Was it helpful?

Solution

It is an attr_accessor for the @rendered instance variable, which is set by the render method in ActionView::TestCase::Behavior. See https://github.com/rails/rails/blob/master/actionpack/lib/action_view/test_case.rb#L108-112.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top