Sha256: e1000006acc56293dd63714b1e4b067c49540c65b4ff13e69becbf9886de20e9
Contents?: true
Size: 1005 Bytes
Versions: 6
Compression:
Stored size: 1005 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 it "passes along any block to the instance method" do klass = Class.new do static_facade :foo def foo yield end end assert klass.foo { :bar } == :bar end end
Version data entries
6 entries across 6 versions & 1 rubygems