File: view_assigns.rb

package info (click to toggle)
ruby-rspec-rails 8.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 1,804 kB
  • sloc: ruby: 10,881; sh: 198; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 631 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module RSpec
  module Rails
    # Helpers for making instance variables available to views.
    module ViewAssigns
      # Assigns a value to an instance variable in the scope of the
      # view being rendered.
      #
      # @example
      #
      #     assign(:widget, stub_model(Widget))
      def assign(key, value)
        _encapsulated_assigns[key] = value
      end

      # Compat-shim for AbstractController::Rendering#view_assigns
      def view_assigns
        super.merge(_encapsulated_assigns)
      end

    private

      def _encapsulated_assigns
        @_encapsulated_assigns ||= {}
      end
    end
  end
end