Sha256: efd34f9f443efb8f547e3aa37b47ff6ae861c63a9b884d33cf860e5c3551c16e

Contents?: true

Size: 1.55 KB

Versions: 7

Compression:

Stored size: 1.55 KB

Contents

# encoding: utf-8

require File.expand_path('../spec_helper.rb', __FILE__)

describe 'Backup::Configuration' do

  after do
    Backup::Configuration.send(:remove_const, 'Foo')
  end

  it 'should create modules for missing constants' do
    Backup::Configuration::Foo.class.should == Module
  end

  describe 'a generated module' do

    before do
      module Backup
        class Foo; end
      end
    end

    after do
      Backup.send(:remove_const, 'Foo')
    end

    it 'should create modules for missing constants' do
      Backup::Configuration::Foo::A::B.class.should == Module
    end

    it 'should pass calls to .defaults to the proper class' do
      Backup::Logger.expects(:warn)
      Backup::Foo.expects(:defaults)
      Backup::Configuration::Foo.defaults
    end

    it 'should pass a given block to .defaults to the proper class' do
      Backup::Logger.expects(:warn)
      configuration = mock
      Backup::Foo.expects(:defaults).yields(configuration)
      configuration.expects(:foo=).with('bar')

      Backup::Configuration::Foo.defaults do |config|
        config.foo = 'bar'
      end
    end

    it 'should log a deprecation warning' do
      Backup::Foo.stubs(:defaults)
      Backup::Logger.expects(:warn).with do |err|
        err.message.should ==
        "ConfigurationError: [DEPRECATION WARNING]\n" +
        "  Backup::Configuration::Foo.defaults is being deprecated.\n" +
        "  To set pre-configured defaults for Backup::Foo, use:\n" +
        "  Backup::Foo.defaults"
      end
      Backup::Configuration::Foo.defaults
    end

  end

end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
backup-agoddard-3.0.28 spec/configuration_spec.rb
backup-agoddard-3.0.27 spec/configuration_spec.rb
ey-vendored-backup-3.0.27 spec/configuration_spec.rb
backup-3.0.27 spec/configuration_spec.rb
backup-3.0.26 spec/configuration_spec.rb
backup-3.0.25 spec/configuration_spec.rb
backup-3.0.24 spec/configuration_spec.rb