Sha256: bc28a8482c34209326adc736c21ef7755f90cd317e657f315d153a69d9806d47

Contents?: true

Size: 1.69 KB

Versions: 26

Compression:

Stored size: 1.69 KB

Contents

require 'test_helper'

module Vedeu

  describe Options do

    let(:described) { Vedeu::Options }
    let(:instance)  { described.new(options, defaults) }
    let(:options)   {}
    let(:defaults)  {}

    describe '#initialize' do
      subject { instance }

      it { instance.must_be_instance_of(described) }

      context 'when the options are nil and defaults are nil' do
        it { instance.instance_variable_get('@options').must_equal({}) }
        it { instance.instance_variable_get('@defaults').must_equal({}) }
      end

      context 'when the options are empty and the defaults are empty' do
        let(:options)  { {} }
        let(:defaults) { {} }

        it { instance.instance_variable_get('@options').must_equal({}) }
        it { instance.instance_variable_get('@defaults').must_equal({}) }
      end

      context 'when an option is set but no default is set' do
        let(:options)  { { element: :hydrogen } }
        let(:defaults) { {} }

        it { (instance.methods - Object.methods).must_equal([:element]) }
        it { instance.element.must_equal(:hydrogen) }
      end

      context 'when an option is set but a default is set' do
        let(:options)  { { element: :lithium } }
        let(:defaults) { { element: :helium } }

        it { (instance.methods - Object.methods).must_equal([:element]) }
        it { instance.element.must_equal(:lithium) }
      end

      context 'when no option is set but a default is set' do
        let(:options)  { {} }
        let(:defaults) { { element: :beryllium } }

        it { (instance.methods - Object.methods).must_equal([:element]) }
        it { instance.element.must_equal(:beryllium) }
      end
    end

  end # Options

end # Vedeu

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
vedeu-0.6.10 test/lib/vedeu/options_test.rb
vedeu-0.6.9 test/lib/vedeu/options_test.rb
vedeu-0.6.8 test/lib/vedeu/options_test.rb
vedeu-0.6.7 test/lib/vedeu/options_test.rb
vedeu-0.6.6 test/lib/vedeu/options_test.rb
vedeu-0.6.5 test/lib/vedeu/options_test.rb