Sha256: 9705c9d0f3f181f748dcff06722f06c0596613af053cfc5a0299239f64b4e115

Contents?: true

Size: 1.83 KB

Versions: 26

Compression:

Stored size: 1.83 KB

Contents

require File.dirname(__FILE__) + '/../../../../../spec_helper'
include OpenEHR::AM::Archetype::Assertion

describe Assertion do
  before(:each) do
    expression = stub(ExprItem, :type => 'Boolean')
    $string_expression = "/[at0001]/speed[at0002]/kilometres/magnitude = " +
      "/[at0003]/speed[at0004]/miles/magnitude * 1.6"
    variables = stub(Array, :size => 2)
    @assertion = OpenEHR::AM::Archetype::Assertion::Assertion.new(:tag => 'validity',
                               :expression => expression,
                               :string_expression => $string_expression,
                               :variables => variables)
  end

  it 'should be an instance of Assertion' do
    @assertion.should be_an_instance_of OpenEHR::AM::Archetype::Assertion::Assertion
  end

  it 'expression should be assigned properly' do
    @assertion.expression.type.should == 'Boolean'
  end

  it 'should raise ArgumentError when expression is nil' do
    lambda {
      @assertion.expression = nil
    }.should raise_error ArgumentError
  end

  it 'should raise ArgumentError when expression type is not Boolean' do
    invalid_expression = stub(ExprItem, :type => 'Real')
    lambda {
      @assertion.expression = invalid_expression
    }.should raise_error ArgumentError
  end

  it 'tag should be assigned properly' do
    @assertion.tag.should == 'validity'
  end

  it 'tag should not be empty' do
    lambda {
      @assertion.tag = ''
    }.should raise_error ArgumentError
  end

  it 'should not raise ArgumentError when tag = nil' do
    lambda {
      @assertion.tag = nil
    }.should_not raise_error ArgumentError
  end

  it 'string_expression should be assigned properly' do
    @assertion.string_expression.should == $string_expression
  end

  it 'variables should be assigned properly' do
    @assertion.variables.size.should be_equal 2
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
openehr-1.2.8 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.2.7 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.2.6 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.2.5 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.2.4 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.2.3 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.2.2 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.2.1 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.2.0 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.1.6 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.1.5 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.1.4 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.1.3 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.1.2 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.1.1 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
openehr-1.1.0 spec/lib/openehr/am/archetype/assertion/assertion_spec.rb
open_ehr-1.0.2 spec/lib/open_ehr/am/archetype/assertion/assertion_spec.rb
open_ehr-1.0.1 spec/lib/open_ehr/am/archetype/assertion/assertion_spec.rb
open_ehr-1.0.0 spec/lib/open_ehr/am/archetype/assertion/assertion_spec.rb
open_ehr-0.9.5 spec/lib/open_ehr/am/archetype/assertion/assertion_spec.rb