Class: RSpec::Rails::ControllerExampleGroup::ClassMethods::DescribedClassDeprecation

Inherits:
Module
  • Object
show all
Defined in:
lib/rspec/rails/example/controller_example_group.rb

Instance Method Summary (collapse)

Constructor Details

- (DescribedClassDeprecation) initialize(value)

Returns a new instance of DescribedClassDeprecation



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/rspec/rails/example/controller_example_group.rb', line 87

def initialize(value)
  module_eval do
    define_method :store_computed do |key|
      return super(key) unless key == :described_class

      RSpec.warn_deprecation(<<-EOS.gsub(/^\s+\|/,''))
        |In RSpec 3, the `controller { }` macro no longer changes
        |`described_class` to refer to the generated anonymous controller
        |class. Instead of `described_class`, use `controller_class` to
        |access the generated anonymous class.
        |(`described_class` called from #{::RSpec::CallerFilter.first_non_rspec_line}.)
      EOS
      store(:described_class, value)
    end
  end
end