Sha256: cc832d6dbe6299a702d86b061af4b8f6a7307ca8d37083b3c19efe16a82b3568

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe AbstractType, '.create_new_method' do
  context 'with arguments' do
    subject { object.new(:foo) }

    let(:abstract_type) do
      Class.new do
        include AbstractType

        def initialize(foo)
          @foo = foo
        end
      end
    end

    it_behaves_like 'AbstractType.create_new_method'
  end

  context 'with a block' do
    subject { object.new(:foo) { nil } }

    let(:abstract_type) do
      Class.new do
        include AbstractType

        def initialize(foo)
          @foo = foo
          yield
        end
      end
    end

    it_behaves_like 'AbstractType.create_new_method'
  end

  context 'without arguments' do
    subject { object.new }

    let(:abstract_type) { Class.new { include AbstractType } }

    it_behaves_like 'AbstractType.create_new_method'
  end

  context 'on an class that doesn\'t have Object as its superclass' do
    subject { object.new }

    let(:abstract_type) { Class.new(RuntimeError) { include AbstractType } }

    it_behaves_like 'AbstractType.create_new_method'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
abstract_type-0.0.7 spec/unit/abstract_type/module_methods/create_new_method_spec.rb