Sha256: 064f8b49a95c49b59d2dc86c1ac103609c4d4e34cec61c183e5a2b8a5877a070

Contents?: true

Size: 1.82 KB

Versions: 6

Compression:

Stored size: 1.82 KB

Contents

module ModuleExample
  include BubbleWrap::Deprecated

  module_function

  def a_method
    @called = true
  end

  deprecated :a_method, "100.0.0"
end

class ClassExample
  include BubbleWrap::Deprecated

  def a_method
    @called = true
  end
  deprecated :a_method, "100.0.0"
end

module BubbleWrap
  def self.set_version(version)
    define_singleton_method("version") do
      version
    end
  end
end

describe BubbleWrap::Deprecated do
  describe ".deprecated" do
    describe "on a module method" do
      describe "with valid version" do
        it "should not raise an exception" do
          should.not.raise(BubbleWrap::Deprecated::DeprecatedError) {
            ModuleExample.a_method
          }
        end
      end

      describe "with invalid version" do
        before do
          @old_version = BubbleWrap.version
          BubbleWrap.set_version("100.0.0")
        end
        after do
          BubbleWrap.set_version(@old_version)
        end

        it "should raise an exception" do
          should.raise(BubbleWrap::Deprecated::DeprecatedError) {
            ModuleExample.a_method
          }
        end
      end
    end

    describe "on an instance method" do
      describe "with valid version" do
        it "should not raise an exception" do
          should.not.raise(BubbleWrap::Deprecated::DeprecatedError) {
            ClassExample.new.a_method
          }
        end
      end

      describe "with invalid version" do
        before do
          @old_version = BubbleWrap.version
          BubbleWrap.set_version("100.0.0")
        end
        after do
          BubbleWrap.set_version(@old_version)
        end

        it "should raise an exception" do
          should.raise(BubbleWrap::Deprecated::DeprecatedError) {
            ClassExample.new.a_method
          }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bubble-wrap-1.8.0 spec/motion/util/deprecated_spec.rb
bubble-wrap-1.7.1 spec/motion/util/deprecated_spec.rb
bubble-wrap-1.7.0 spec/motion/util/deprecated_spec.rb
bubble-wrap-1.6.0 spec/motion/util/deprecated_spec.rb
bubble-wrap-1.6.0.rc1 spec/motion/util/deprecated_spec.rb
bubble-wrap-1.5.0 spec/motion/util/deprecated_spec.rb