Sha256: d5bc47b1a7efd2e948ace17489c6fdd75e6fa32edcb7de7f418881c78bf0483b

Contents?: true

Size: 1.24 KB

Versions: 17

Compression:

Stored size: 1.24 KB

Contents

require 'test_helper'

module Vedeu

  class VedeuCommonClass

    include Vedeu::Common

    def defined_value_test(variable)
      defined_value?(variable)
    end

  end # VedeuCommonClass

  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

17 entries across 17 versions & 1 rubygems

Version Path
vedeu-0.4.11 test/lib/vedeu/support/common_test.rb
vedeu-0.4.10 test/lib/vedeu/support/common_test.rb
vedeu-0.4.9 test/lib/vedeu/support/common_test.rb
vedeu-0.4.8 test/lib/vedeu/support/common_test.rb
vedeu-0.4.7 test/lib/vedeu/support/common_test.rb
vedeu-0.4.6 test/lib/vedeu/support/common_test.rb
vedeu-0.4.5 test/lib/vedeu/support/common_test.rb
vedeu-0.4.4 test/lib/vedeu/support/common_test.rb
vedeu-0.4.3 test/lib/vedeu/support/common_test.rb
vedeu-0.4.2 test/lib/vedeu/support/common_test.rb
vedeu-0.4.1 test/lib/vedeu/support/common_test.rb
vedeu-0.4.0 test/lib/vedeu/support/common_test.rb
vedeu-0.3.5 test/lib/vedeu/support/common_test.rb
vedeu-0.3.4 test/lib/vedeu/support/common_test.rb
vedeu-0.3.3 test/lib/vedeu/support/common_test.rb
vedeu-0.3.2 test/lib/vedeu/support/common_test.rb
vedeu-0.3.1 test/lib/vedeu/support/common_test.rb