RSpec-rails. The rendered method
The render开发者_开发技巧ed
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.
精彩评论