Sha256: 428cdc204b0b3a0753237503b4c2479c4a1d640f662d8aa924c7946ffdf95497

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

# encoding: UTF-8
#
# Copyright 2011 Brennan Frydl (http://bfrydl.com/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'spec_helper'

describe Settis::Container do
  before :each do
    @class = Class.new do
      extend Settis::Container
    end
  end

  describe '#root' do
    it 'stores the root namespace prefix for Redis keys' do
      @class.root.should == 'settings'
      @class.root 'test'
      @class.root.should == 'test'
    end
  end

  describe '#redis' do
    it 'returns a Redis::Namespace specific to the container' do
      stub(@class).root { 'configuration' }

      @class.redis.should be_a(Redis::Namespace)
      @class.redis.namespace.should == 'configuration'
    end
  end

  describe '#setting' do
    it 'defines a new setting' do
      mock(Settis::Settings::Scalar).new('title', @class, :default => 'Hello World')

      @class.setting :title, :string, :default => 'Hello World'
    end

    it 'does not allow duplicate names' do
      stub(Settis::Settings::Scalar).new.once
      @class.setting :title, :string

      expect { @class.setting :title, :integer }.to raise_error(ArgumentError)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
settis-0.1.0 spec/settis/container_spec.rb