Sha256: 6aa82761788c13915f11aa6ec5952cd93de0149c93b08bc67c5adfd9674c46a3

Contents?: true

Size: 806 Bytes

Versions: 3

Compression:

Stored size: 806 Bytes

Contents

require "spec_helper"

describe Object, ".static_facade" do
  it "creates a class method that instantiates and runs that instance method" do
    klass = Class.new do
      static_facade :fooable?,
        :foo

      def fooable?
        foo
      end
    end

    assert klass.fooable?(true)
    refute klass.fooable?(false)
  end

  it "doesn't require attributes" do
    klass = Class.new do
      static_facade :fooable?

      def fooable?
        true
      end
    end

    assert klass.fooable?
  end

  it "accepts multiple method names" do
    klass = Class.new do
      static_facade [ :fooable?, :barable? ],
        :foo

      def fooable?
        foo
      end

      def barable?
        not foo
      end
    end

    assert klass.fooable?(true)
    assert klass.barable?(false)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attr_extras-5.1.0 spec/attr_extras/static_facade_spec.rb
attr_extras-5.0.0 spec/attr_extras/static_facade_spec.rb
attr_extras-4.6.0 spec/attr_extras/static_facade_spec.rb