Module: RSpec::Rails::ViewAssigns

### Home Classes Methods

### In Files

- lib/rspec/rails/view_assigns.rb

### Methods

- #_assigns
- #assign
- #view_assigns

### Files

- fixture

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Rails
- RSpec::Rails::AssertionDelegator
- RSpec::Rails::ControllerExampleGroup
- RSpec::Rails::ControllerExampleGroup::BypassRescue
- RSpec::Rails::ControllerExampleGroup::ClassMethods
- RSpec::Rails::Extensions
- RSpec::Rails::Extensions::ActiveRecord
- RSpec::Rails::FeatureExampleGroup
- RSpec::Rails::FixtureSupport
- RSpec::Rails::HelperExampleGroup
- RSpec::Rails::HelperExampleGroup::ClassMethods
- RSpec::Rails::IllegalDataAccessException
- RSpec::Rails::MailerExampleGroup
- RSpec::Rails::MailerExampleGroup::ClassMethods
- RSpec::Rails::Matchers
- RSpec::Rails::Matchers::BeANew
- RSpec::Rails::Matchers::BeANewRecord
- RSpec::Rails::Matchers::BeValid
- RSpec::Rails::Matchers::HaveExtensions
- RSpec::Rails::Matchers::RedirectTo
- RSpec::Rails::Matchers::RedirectTo::RedirectTo
- RSpec::Rails::Matchers::RenderTemplate
- RSpec::Rails::Matchers::RenderTemplate::RenderTemplateMatcher
- RSpec::Rails::Matchers::RoutingMatchers
- RSpec::Rails::Matchers::RoutingMatchers::BeRoutableMatcher
- RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers
- RSpec::Rails::Matchers::RoutingMatchers::RouteToMatcher
- RSpec::Rails::MiniTestLifecycleAdapter
- RSpec::Rails::MinitestCounters
- RSpec::Rails::Mocks
- RSpec::Rails::Mocks::ActiveModelInstanceMethods
- RSpec::Rails::Mocks::ActiveModelStubExtensions
- RSpec::Rails::Mocks::ActiveRecordInstanceMethods
- RSpec::Rails::Mocks::ActiveRecordStubExtensions
- RSpec::Rails::ModelExampleGroup
- RSpec::Rails::ModuleInclusion
- RSpec::Rails::RailsExampleGroup
- RSpec::Rails::Railtie
- RSpec::Rails::RequestExampleGroup
- RSpec::Rails::RoutingExampleGroup
- RSpec::Rails::RoutingExampleGroup::ClassMethods
- RSpec::Rails::SetupAndTeardownAdapter
- RSpec::Rails::SetupAndTeardownAdapter::ClassMethods
- RSpec::Rails::TestUnitAssertionAdapter
- RSpec::Rails::TestUnitAssertionAdapter::AssertionDelegator
- RSpec::Rails::TestUnitAssertionAdapter::ClassMethods
- RSpec::Rails::Version
- RSpec::Rails::ViewAssigns
- RSpec::Rails::ViewExampleGroup
- RSpec::Rails::ViewExampleGroup::ClassMethods
- RSpec::Rails::ViewExampleGroup::ExampleMethods
- RSpec::Rails::ViewRendering
- RSpec::Rails::ViewRendering::ClassMethods
- RSpec::Rails::ViewRendering::EmptyTemplateHandler
- RSpec::Rails::ViewRendering::EmptyTemplatePathSetDecorator
- RSpec::Rails::ViewRendering::EmptyTemplates
- Rspec
- Rspec::Generators
- Rspec::Generators::Base
- Rspec::Generators::ControllerGenerator
- Rspec::Generators::HelperGenerator
- Rspec::Generators::InstallGenerator
- Rspec::Generators::IntegrationGenerator
- Rspec::Generators::MailerGenerator
- Rspec::Generators::ModelGenerator
- Rspec::Generators::ObserverGenerator
- Rspec::Generators::ScaffoldGenerator
- Rspec::Generators::ViewGenerator
- Rails
- Rails::Generators
- Rails::Generators::GeneratedAttribute
- Test
- Test::Unit
- Test::Unit::AssertionFailedError
- ActiveModel
- ActiveModel::Validations
- ActiveRecord
- ActiveRecord::Base
- Autotest
- Autotest::RailsRspec2
- Object
- RequestInstanceMethods

No matching classes.

# RSpec::Rails::ViewAssigns

### Public Instance Methods

_assigns() click to toggle source

@api private

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

assign(key, value) click to toggle source

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

@example

    assign(:widget, stub_model(Widget))

    # File lib/rspec/rails/view_assigns.rb, line 10
    def assign(key, value)
      _encapsulated_assigns[key] = value
    end

view_assigns() click to toggle source

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.