$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'spec' require 'buildmaster/tree_to_object' module BuildMaster class SampleObject attr_reader :field_one, :field_two, :object_two, :array_field attr_writer :field_one, :field_two def initialize @object_two = SampleTwo.new @array_field = Array.new end def add_to_array_field item = SampleTwo.new @array_field.push(item) return item end end class SampleTwo attr_reader :field, :index attr_writer :field, :index end context 'TreeToObjectTest' do specify 'should_populate_string_fields' do content = < error error.message.include?('not_field').should_equal true error.message.include?('string').should_equal true end end specify 'should_raise_error_if_sub_property_not_found' do content = < error error.message.include?('not_sub_property').should_equal true error.message.include?('sub property').should_equal true end end specify 'should_raise_error_if_array_property_not_found' do content = < error error.message.include?('not_array_property').should_equal true error.message.include?('array').should_equal true end end specify 'empty_content' do object = TreeToObject.from_yaml('', SampleObject.new) object.field_one.should_equal nil end end end