Sha256: fa228fe0b4c7e44395e323d38854f64172b2f072f477f6ec1ad4cc31899c76ee

Contents?: true

Size: 961 Bytes

Versions: 4

Compression:

Stored size: 961 Bytes

Contents

require 'spec_helper'
require 'settingslogic'
require 'settings_js/backends/settings_logic'

describe 'SettingsJs::Backends::SettingsLogic' do

  let(:settings_klass) do
    Class.new(Settingslogic) do
      source File.join(Spec_root, 'fixtures', 'settings_js', 'backends', 'settings_logic.yml')
    end
  end

  let(:backend_instance) { SettingsJs::Backends::SettingsLogic.new(settings_klass) }

  it { backend_instance.should have_attr_accessor(:klass) }

  describe '#to_hash' do
    it 'returns subkeys when base key is in settings root' do
      backend_instance.to_hash('key1').should == { 'sub_key1' => 'sub_value1' }
    end

    it 'returns subkeys when base key is under the settings root' do
      expected_hash = {
        'sub_key2_2_1' => 'sub_value2_2_1' ,
        'sub_key2_2_2' => {
          'sub_key2_2_2_1' => 'sub_value2_2_2_1'
        }
      }

      backend_instance.to_hash('key2.sub_key2_2').should == expected_hash
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
settings_js-0.2.0 spec/settings_js/backends/settings_js_spec.rb
settings_js-0.1.2 spec/settings_js/backends/settings_js_spec.rb
settings_js-0.1.1 spec/settings_js/backends/settings_js_spec.rb
settings_js-0.1.0 spec/settings_js/backends/settings_js_spec.rb