문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top