Module: RSpec::Rails::ViewAssigns

Included in:
HelperExampleGroup, ViewExampleGroup
Defined in:
lib/rspec/rails/view_assigns.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) _assigns

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

33
34
35
# File 'lib/rspec/rails/view_assigns.rb', line 33
def _assigns
  super.merge(_encapsulated_assigns)
end

- (Object) assign(key, value)

Assigns a value to an instance variable in the scope of the view being rendered.

Examples:


assign(:widget, stub_model(Widget))
10
11
12
# File 'lib/rspec/rails/view_assigns.rb', line 10
def assign(key, value)
  _encapsulated_assigns[key] = value
end

- (Object) view_assigns

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rspec/rails/view_assigns.rb', line 14
def view_assigns
  begin
    # TODO: _assigns was deprecated in favor of view_assigns after
    # Rails-3.0.0 was released. Since we are not able to predict when
    # the _assigns/view_assigns patch will be released (I thought it
    # would have been in 3.0.1, but 3.0.1 bypassed this change for a
    # security fix), this bit ensures that we do the right thing without
    # knowing anything about the Rails version we are dealing with.
    #
    # Once that change _is_ released, this can be changed to something
    # that checks for the Rails version when the module is being
    # interpreted, as it was before commit dd0095.
    super.merge(_encapsulated_assigns)
  rescue
    _assigns
  end
end