Sha256: b9273aafa4a3df17322dbd99deb6cd008f036f20e97de0703f30ae5fc18ca921

Contents?: true

Size: 1.34 KB

Versions: 25

Compression:

Stored size: 1.34 KB

Contents

require 'test_helper'

module Vedeu

  class VedeuCommonClass

    include Vedeu::Common

    def defined_value_test(variable)
      present?(variable)
    end

  end # VedeuCommonClass

  describe Common do

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

    describe '#present?' do
      subject { instance.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 '#snake_case' do
      let(:_name) { 'MyFirstApp' }

      subject { instance.snake_case(_name) }

      it { subject.must_equal('my_first_app') }

      context 'when namespaced' do
        let(:_name) { 'MyFirstApp::SomeController' }

        it { subject.must_equal('my_first_app/some_controller') }
      end
    end

  end # Common

end # Vedeu

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
vedeu-0.5.0 test/lib/vedeu/common_test.rb
vedeu-0.4.65 test/lib/vedeu/common_test.rb
vedeu-0.4.64 test/lib/vedeu/common_test.rb
vedeu-0.4.63 test/lib/vedeu/common_test.rb
vedeu-0.4.62 test/lib/vedeu/common_test.rb
vedeu-0.4.61 test/lib/vedeu/common_test.rb
vedeu-0.4.60 test/lib/vedeu/common_test.rb
vedeu-0.4.59 test/lib/vedeu/common_test.rb
vedeu-0.4.58 test/lib/vedeu/common_test.rb
vedeu-0.4.57 test/lib/vedeu/common_test.rb
vedeu-0.4.56 test/lib/vedeu/common_test.rb
vedeu-0.4.55 test/lib/vedeu/common_test.rb
vedeu-0.4.54 test/lib/vedeu/support/common_test.rb
vedeu-0.4.53 test/lib/vedeu/support/common_test.rb
vedeu-0.4.52 test/lib/vedeu/support/common_test.rb
vedeu-0.4.51 test/lib/vedeu/support/common_test.rb
vedeu-0.4.50 test/lib/vedeu/support/common_test.rb
vedeu-0.4.49 test/lib/vedeu/support/common_test.rb
vedeu-0.4.48 test/lib/vedeu/support/common_test.rb
vedeu-0.4.47 test/lib/vedeu/support/common_test.rb