Sha256: 6b825127aa7f692e950b59a0d6e5547d73e4d813a410cdc825a191b1ceb6ca1c

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe AbstractType::AbstractMethodDeclarations,
         '#abstract_singleton_method' do
  subject { object.abstract_singleton_method(:some_method) }

  let(:object)   { Class.new { include AbstractType } }
  let(:subclass) { Class.new(object)                  }

  before do
    Subclass = subclass
  end

  after do
    Object.class_eval { remove_const(:Subclass) }
  end

  it { should equal(object) }

  it 'creates an abstract method' do
    expect { subject }.to change { subclass.respond_to?(:some_method) }
      .from(false)
      .to(true)
  end

  it 'creates an abstract method with the expected arity' do
    subject
    expect(object.method(:some_method).arity).to be(-1)
  end

  it 'creates a method that raises an exception' do
    subject
    expect { subclass.some_method }.to raise_error(
      NotImplementedError,
      'Subclass.some_method is not implemented'
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
abstract_type-0.0.7 spec/unit/abstract_type/abstract_method_declarations/abstract_singleton_method_spec.rb