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.30 test/lib/vedeu/options_test.rb
vedeu-0.6.29 test/lib/vedeu/options_test.rb
vedeu-0.6.28 test/lib/vedeu/options_test.rb
vedeu-0.6.27 test/lib/vedeu/options_test.rb
vedeu-0.6.26 test/lib/vedeu/options_test.rb
vedeu-0.6.25 test/lib/vedeu/options_test.rb
vedeu-0.6.24 test/lib/vedeu/options_test.rb
vedeu-0.6.23 test/lib/vedeu/options_test.rb
vedeu-0.6.22 test/lib/vedeu/options_test.rb
vedeu-0.6.21 test/lib/vedeu/options_test.rb
vedeu-0.6.20 test/lib/vedeu/options_test.rb
vedeu-0.6.19 test/lib/vedeu/options_test.rb
vedeu-0.6.18 test/lib/vedeu/options_test.rb
vedeu-0.6.17 test/lib/vedeu/options_test.rb
vedeu-0.6.16 test/lib/vedeu/options_test.rb
vedeu-0.6.15 test/lib/vedeu/options_test.rb
vedeu-0.6.14 test/lib/vedeu/options_test.rb
vedeu-0.6.13 test/lib/vedeu/options_test.rb
vedeu-0.6.12 test/lib/vedeu/options_test.rb
vedeu-0.6.11 test/lib/vedeu/options_test.rb