Sha256: fd8d9f3bbeac418d9397976dd702024d4d2ecfbe44e3abf73b43abd0533931ff

Contents?: true

Size: 475 Bytes

Versions: 5

Compression:

Stored size: 475 Bytes

Contents

require "spec_helper"

describe Object, ".method_object" do
  it "creates a .call class method that instantiates and runs the #call instance method" do
    klass = Class.new do
      method_object :foo

      def call
        foo
      end
    end

    assert klass.call(true)
    refute klass.call(false)
  end

  it "doesn't require attributes" do
    klass = Class.new do
      method_object

      def call
        true
      end
    end

    assert klass.call
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
attr_extras-5.1.0 spec/attr_extras/method_object_spec.rb
attr_extras-5.0.0 spec/attr_extras/method_object_spec.rb
attr_extras-4.6.0 spec/attr_extras/method_object_spec.rb
attr_extras-4.5.0 spec/attr_extras/method_object_spec.rb
attr_extras-4.4.0 spec/attr_extras/method_object_spec.rb