Sha256: 43e67e282ceef337d825303cd62b09d1e9e09ba3de18d847886c824eb630dd3e

Contents?: true

Size: 935 Bytes

Versions: 8

Compression:

Stored size: 935 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Mutant, '.singleton_subclass_instance' do
  let(:object) { described_class }

  subject { object.singleton_subclass_instance(name, superclass, &block) }

  before do
    subject
  end

  let(:name)       { 'Test'                }
  let(:block)      { proc { def foo; end } }
  let(:superclass) { Class.new             }

  let(:generated) { superclass.const_get(:Test) }

  it_should_behave_like 'a command method'

  it 'sets expected name' do
    name = generated.class.name
    name.should eql("::#{self.name}")
    name.should be_frozen
  end

  it 'stores instance of subclass' do
    generated.should be_kind_of(superclass)
  end

  it 'evaluates the context of proc inside subclass' do
    generated.should respond_to(:foo)
  end

  it 'generates nice #inspect' do
    inspect = generated.inspect
    inspect.should eql("::#{self.name}")
    inspect.should be_frozen
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutant-0.3.1 spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb
mutant-0.3.0 spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb
mutant-0.3.0.rc5 spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb
mutant-0.3.0.rc4 spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb
mutant-0.3.0.rc3 spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb
mutant-0.3.0.rc2 spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb
mutant-0.3.0.rc1 spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb
mutant-0.3.0.beta22 spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb