Sha256: f6dfead711a9e1e1cd9512784c2852b0be89202b18a7cd8091da10e36a9b5030

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

describe Scorpion::ObjectConstructor do
   it 'defined an initializer' do
      klass = Class.new do
        include Scorpion::Object

        initialize logger: String
      end

      expect( klass.instance_method(:initialize).arity ).to eq 1
    end

    it "executes initializer code" do
      expect do |b|
        klass = Class.new do
          include Scorpion::Object

          initialize label: String, &b
        end

        klass.new "home"
      end.to yield_control
    end

    it "creates an initializer that accepts a block" do
      klass = Class.new do
        include Scorpion::Object

        initialize label: String do |&block|
          block.call
        end
      end

      expect do |b|
        klass.new "apples", &b
      end.to yield_control
    end

    it "it defines matching attributes" do
      klass = Class.new do
        include Scorpion::Object

        initialize label: String
      end

      expect( klass.new( "apples" ).label ).to eq "apples"
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scorpion-ioc-0.4.0 spec/lib/scorpion/object_constructor_spec.rb