Sha256: e48c9b16de9062c3936531a26769fe32da2ccc8b5eab5d343f0446da67f82f04

Contents?: true

Size: 1018 Bytes

Versions: 13

Compression:

Stored size: 1018 Bytes

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

  end # Common

end # Vedeu

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
vedeu-0.4.29 test/lib/vedeu/support/common_test.rb
vedeu-0.4.28 test/lib/vedeu/support/common_test.rb
vedeu-0.4.27 test/lib/vedeu/support/common_test.rb
vedeu-0.4.26 test/lib/vedeu/support/common_test.rb
vedeu-0.4.25 test/lib/vedeu/support/common_test.rb
vedeu-0.4.24 test/lib/vedeu/support/common_test.rb
vedeu-0.4.23 test/lib/vedeu/support/common_test.rb
vedeu-0.4.22 test/lib/vedeu/support/common_test.rb
vedeu-0.4.21 test/lib/vedeu/support/common_test.rb
vedeu-0.4.20 test/lib/vedeu/support/common_test.rb
vedeu-0.4.19 test/lib/vedeu/support/common_test.rb
vedeu-0.4.18 test/lib/vedeu/support/common_test.rb
vedeu-0.4.17 test/lib/vedeu/support/common_test.rb