Changeset 380 for ruby/trunk


Ignore:
Timestamp:
Dec 20, 2009, 8:20:02 PM (14 years ago)
Author:
KOBAYASHI, Shinji
Message:

refs #74, #71

Location:
ruby/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb

    r379 r380  
    150150
    151151        class CDefinedObject < CObject
    152           attr_accessor :assumed_value, :any_allowed
     152          attr_accessor :assumed_value
    153153         
    154154          def initialize(args = { })
     
    168168            raise NotImplementedError, 'subclass should implement this method'
    169169          end
     170
     171          def any_allowed?
     172            raise NotImplementedError, 'subclass should implement this method'
     173          end
    170174        end
    171175
     
    174178
    175179          def initialize(args = { })
    176             @attributes = args[:item] if args[:item]
    177             super
     180            super
     181            self.item = args[:item]
     182          end
     183
     184          def any_allowed?
     185            return !item.nil?
    178186          end
    179187        end
  • ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_defined_object_spec.rb

    r379 r380  
    4242    }.should raise_error NotImplementedError
    4343  end
     44
     45  it 'any_allowed should raise NotImplementedError' do
     46    lambda {
     47      @c_defined_object.any_allowed?
     48    }.should raise_error NotImplementedError
     49  end
    4450end
    4551
  • ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb

    r375 r380  
    11require File.dirname(__FILE__) + '/../../../../../spec_helper'
    22include OpenEHR::AM::Archetype::ConstraintModel
     3include OpenEHR::AM::Archetype::Primitive
    34include OpenEHR::AssumedLibraryTypes
    45
     
    67  before(:each) do
    78    interval = Interval.new(:lower => 0, :upper => 1)
     9    item = stub(CPrimitive, :node_id => 'at0001')
    810    @c_primitive_object = CPrimitiveObject.new(:path => 'event/test',
    911                                               :rm_type_name => 'DV_TEXT',
    1012                                               :node_id => 'ac0001',
    11                                                :occurrences => interval)
     13                                               :occurrences => interval,
     14                                               :item => item)
    1215  end
    1316
     
    1518    @c_primitive_object.should be_an_instance_of CPrimitiveObject
    1619  end
     20
     21  it 'item should be assigned properly' do
     22    @c_primitive_object.item.node_id.should == 'at0001'
     23  end
     24
     25  it 'should allowed any' do
     26    @c_primitive_object.should be_any_allowed
     27  end
     28
     29  it 'should not any allowed' do
     30    @c_primitive_object.item = nil
     31    @c_primitive_object.should_not be_any_allowed
     32  end
    1733end
Note: See TracChangeset for help on using the changeset viewer.