Skip to content

Instantly share code, notes, and snippets.

@jmoody
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmoody/c23419118f19fa61db1b to your computer and use it in GitHub Desktop.
Save jmoody/c23419118f19fa61db1b to your computer and use it in GitHub Desktop.
deprecate a ruby constant
def self.const_missing(const_name)
if const_name == :FRAMEWORK_VERSION
_deprecated('0.9.169', 'no replacement', :warn)
return nil
end
raise(NameError, "uninitialized constant Calabash::Cucumber::#{const_name}")
end
@jmoody
Copy link
Author

jmoody commented May 26, 2014

require 'spec_helper'

describe 'version module' do

  it 'should deprecate FRAMEWORK_VERSION cleanly' do
    expect(Calabash::Cucumber::FRAMEWORK_VERSION).to be == nil
  end

  it 'should handle non-defined constants with NameError' do
    expect{ Calabash::Cucumber::MISSING_CONSTANT }.to raise_error(NameError, 'uninitialized constant Calabash::Cucumber::MISSING_CONSTANT')
  end

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment