Module: RSpec::Expectations::DeprecatedConstants

Defined in:
lib/rspec/expectations/extensions/object.rb

Instance Method Summary collapse

Instance Method Details

#const_missing(name) ⇒ Object

Displays deprecation warning when it captures Rspec and Spec. Otherwise delegates to super.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rspec/expectations/extensions/object.rb', line 6

def const_missing(name)
  case name
  when :Rspec, :Spec
    RSpec.warn_deprecation "*****************************************************************\nDEPRECATION WARNING: you are using a deprecated constant that will\nbe removed from a future version of RSpec.\n\n\#{caller(0)[2]}\n\n* \#{name} is deprecated.\n* RSpec is the new top-level module in RSpec-2\n***************************************************************\n"
    RSpec
  else
    begin
      super
    rescue Exception => e
      e.backtrace.reject! {|l| l =~ Regexp.compile(__FILE__) }
      raise e
    end
  end
end