Sha256: 5de0f5927a29ffd96a57da89dc92e003385397ebf209295fccd5440f21f7b2c0

Contents?: true

Size: 1.37 KB

Versions: 69

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'
require 'stringio'

describe EY::Serverside do
  before do
    @original_stderr = $stderr
    @warnings = StringIO.new
    $stderr = @warnings
  end

  after do
    $stderr = @original_stderr
  end

  def check_deprecation(new_const, prints_warning = true)
    old_name = new_const.to_s.gsub('EY::Serverside::', 'EY::')
    eval(old_name).should == new_const
    @warnings.string.should include(old_name) if prints_warning
  end

  it "preserves the old constants" do
    names = %w[CLI Deploy DeployBase Deploy::Configuration
               DeployHook LockfileParser LoggedOutput Server Task
               Strategies Strategies::Git]

    names.map do |name|
      const = eval("::EY::Serverside::#{name}")
      # The way deprecations are implemented currently, we don't print
      # warning messages for constants that aren't directly under EY::
      prints_warning = name.include?('::') ? false : true
      check_deprecation(const, prints_warning)
    end
  end

  it "deprecates EY.dna_json and EY.node" do
    EY.dna_json.should == EY::Serverside.dna_json
    @warnings.string.should include("EY.dna_json")
    EY.node.should == EY::Serverside.node
    @warnings.string.should include("EY.node")
  end

  it "doesn't interfere with unrelated constants" do
    lambda{ EY::WTFNotDefined }.should raise_error(NameError, /uninitialized constant.*EY::WTFNotDefined/)
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
engineyard-serverside-1.6.5 spec/deprecation_spec.rb
engineyard-serverside-1.6.4 spec/deprecation_spec.rb
engineyard-serverside-1.6.4.pre6 spec/deprecation_spec.rb
engineyard-serverside-1.6.4.pre5 spec/deprecation_spec.rb
engineyard-serverside-1.6.4.pre4 spec/deprecation_spec.rb
engineyard-serverside-1.6.4.pre3 spec/deprecation_spec.rb
engineyard-serverside-1.6.4.pre2 spec/deprecation_spec.rb
engineyard-serverside-1.6.4.pre spec/deprecation_spec.rb
engineyard-serverside-1.6.3 spec/deprecation_spec.rb
engineyard-serverside-1.5.35.pre.2 spec/deprecation_spec.rb
engineyard-serverside-1.5.35.pre.1 spec/deprecation_spec.rb
engineyard-serverside-1.5.33 spec/deprecation_spec.rb
engineyard-serverside-1.5.32 spec/deprecation_spec.rb
engineyard-serverside-1.5.30 spec/deprecation_spec.rb
engineyard-serverside-1.5.29.pre3 spec/deprecation_spec.rb
engineyard-serverside-1.5.29.pre2 spec/deprecation_spec.rb
engineyard-serverside-1.5.29.pre1 spec/deprecation_spec.rb
engineyard-serverside-1.5.29.pre spec/deprecation_spec.rb
engineyard-serverside-1.5.28 spec/deprecation_spec.rb
engineyard-serverside-1.5.28.pre12 spec/deprecation_spec.rb