Sha256: 7760c663c2a53ce14df022b8d412b2b27a7fcae1546c2b824384dae0c9760ac4

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

module Vedeu

  describe Common do

    let(:described) { Vedeu::VedeuCommonClass.new }

    describe '#defined_value?' do
      subject { described.defined_value_test(value) }

      context 'when the variable is a Fixnum' do
        let(:value) { 17 }

        it { subject.must_equal(true) }
      end

      context 'when the variable is not nil or empty' do
        let(:value) { 'not empty' }

        it { subject.must_equal(true) }
      end

      context 'when the variable is nil or empty' do
        let(:value) { [] }

        it { subject.must_equal(false) }
      end

      context 'when dealing with keys which may not exist or have a value' do
        let(:attributes) { {} }
        let(:value)      { attributes[:not_found] }

        it { subject.must_equal(false) }
      end
    end

    describe '#to_sentence' do
      let(:array) { %w{ hydrogen helium lithium } }

      subject { described.to_sentence(array) }

      it { subject.must_be_instance_of(String) }
      it { subject.must_equal('hydrogen, helium and lithium') }
    end

  end # Common

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.3.0 test/lib/vedeu/support/common_test.rb