Sha256: 1d84ff6c1336f58aad0c550b7dd9ceb4b70404eb0cd51446f0d24ecb87e340f7

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

shared_examples_for 'a nested element' do

  # clazz must be defined by the calling file

  let(:nested_element) { clazz.new }


  it 'has a parent element' do
    nested_element.should respond_to(:parent_element)
  end

  it 'can change its parent element' do
    expect(nested_element).to respond_to(:parent_element=)

    nested_element.parent_element = :some_parent_element
    nested_element.parent_element.should == :some_parent_element
    nested_element.parent_element = :some_other_parent_element
    nested_element.parent_element.should == :some_other_parent_element
  end

  it 'starts with no parent element' do
    nested_element.parent_element.should == nil
  end

  it 'has access to its ancestors' do
    nested_element.should respond_to(:get_ancestor)
  end

  it 'gets an ancestor based on type' do
    (clazz.instance_method(:get_ancestor).arity == 1).should be_true
  end

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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cuke_modeler-0.4.1 spec/unit/nested_element_unit_specs.rb
cuke_modeler-0.4.0 spec/unit/nested_element_unit_specs.rb