Methods
P
R
S
T
V
Instance Public methods
params()

Provides access to the params hash that will be available within the view:

params[:foo] = 'bar'
# File rspec/rails/example/view_example_group.rb, line 79
def params
  controller.params
end
render(options={}, local_assigns={}, &block)

@overload render @overload render({:partial => path_to_file}) @overload render({:partial => path_to_file}, {… locals …}) @overload render({:partial => path_to_file}, {… locals …}) do … end

Delegates to ActionView::Base#render, so see documentation on that for more info.

The only addition is that you can call render with no arguments, and RSpec will pass the top level description to render:

describe "widgets/new.html.erb" do
  it "shows all the widgets" do
    render # => view.render(:file => "widgets/new.html.erb")
    # ...
  end
end
# File rspec/rails/example/view_example_group.rb, line 44
def render(options={}, local_assigns={}, &block)
  options = {:template => _default_file_to_render} if Hash === options and options.empty?
  super(options, local_assigns, &block)
end
response()

@deprecated Use `rendered` instead.

# File rspec/rails/example/view_example_group.rb, line 90
def response
  RSpec.deprecate("response", "rendered")
  rendered
end
stub_template(hash)

Simulates the presence of a template on the file system by adding a Rails' FixtureResolver to the front of the view_paths list. Designed to help isolate view examples from partials rendered by the view template that is the subject of the example.

@example

stub_template("widgets/_widget.html.erb" => "This content.")
# File rspec/rails/example/view_example_group.rb, line 71
def stub_template(hash)
  view.view_paths.unshift(ActionView::FixtureResolver.new(hash))
end
template()

@deprecated Use `view` instead.

# File rspec/rails/example/view_example_group.rb, line 84
def template
  RSpec.deprecate("template","view")
  view
end
view()

The instance of `ActionView::Base` that is used to render the template. Use this to stub methods beforecalling `render`.

describe "widgets/new.html.erb" do
  it "shows all the widgets" do
    view.stub(:foo) { "foo" }
    render
    # ...
  end
end
# File rspec/rails/example/view_example_group.rb, line 59
def view
  _view
end