Sha256: 599c65d6f07748bf7ab17074f36720bfcee0eba82052452dbda5db296e06365e

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

require "#{File.dirname(__FILE__)}/../../spec_helper"

shared_examples_for 'a nested model' do

  # clazz must be defined by the calling file

  let(:nested_model) { clazz.new }


  it 'has a parent model' do
    expect(nested_model).to respond_to(:parent_model)
  end

  it 'can change its parent model' do
    expect(nested_model).to respond_to(:parent_model=)

    nested_model.parent_model = :some_parent_model
    expect(nested_model.parent_model).to eq(:some_parent_model)
    nested_model.parent_model = :some_other_parent_model
    expect(nested_model.parent_model).to eq(:some_other_parent_model)
  end


  describe 'abstract instantiation' do

    context 'a new nested object' do

      let(:nested_model) { clazz.new }


      it 'starts with no parent model' do
        expect(nested_model.parent_model).to be_nil
      end

    end

  end

  it 'has access to its ancestors' do
    expect(nested_model).to respond_to(:get_ancestor)
  end

  it 'gets an ancestor based on type' do
    expect(clazz.instance_method(:get_ancestor).arity).to eq(1)
  end

  it 'raises and exception if an unknown ancestor type is requested' do
    expect { nested_model.get_ancestor(:bad_ancestor_type) }.to raise_exception(ArgumentError)
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cuke_modeler-2.1.0 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-2.0.0 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.5.1 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.5.0 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.4.0 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.3.0 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.2.1 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.2.0 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.1.1 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.1.0 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.0.4 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.0.3 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb
cuke_modeler-1.0.2 testing/rspec/spec/unit/shared/nested_models_unit_specs.rb