Sha256: e12ed2d893d26a7946f5f91b8eb6e0b9ef65eb43772e902f2b0126e650836825

Contents?: true

Size: 833 Bytes

Versions: 2

Compression:

Stored size: 833 Bytes

Contents

module RSpec
  module Rails
    module ViewAssigns
      extend ActiveSupport::Concern

      module InstanceMethods
        # :call-seq:
        #   assign(:widget, stub_model(Widget))
        #
        # Assigns a value to an instance variable in the scope of the
        # view being rendered.
        def assign(key, value)
          _encapsulated_assigns[key] = value
        end

        if ::Rails::VERSION::STRING == "3.0.0"
          def _assigns
            super.merge(_encapsulated_assigns)
          end
          def view_assigns
            _assigns
          end
        else # >= 3.0.1
          def view_assigns
            super.merge(_encapsulated_assigns)
          end
        end

      private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-rails-2.0.0 lib/rspec/rails/view_assigns.rb
rspec-rails-2.0.0.rc lib/rspec/rails/view_assigns.rb