Sha256: 6260e2afed60db8b7058e5cef917e42fe7d78a60ed03b15f37eb8098473076cf

Contents?: true

Size: 1.43 KB

Versions: 18

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Mina::Configuration do
  let(:config) { Class.new(Mina::Configuration).instance }
  let(:key) { config.fetch(:key, :default) }

  describe '#set' do
    it 'sets by value' do
      config.set(:key, :value)
      expect(key).to eq :value
    end

    it 'sets by block' do
      config.set(:key) { :value }
      expect(key).to eq :value
    end
  end

  describe '#fetch' do
    it 'returns the default value if key not set' do
      expect(key).to eq :default
    end

    it 'returns ENV value if set' do
      ENV['key'] = 'env'
      expect(key).to eq 'env'
      ENV['key'] = nil
    end
  end

  describe '#set?' do
    it 'returns true if key is set' do
      config.set(:key, :value)
      expect(config.set?(:key)).to be true
    end

    it 'returns false if key is not set' do
      expect(config.set?(:key)).to be false
    end
  end

  describe '#ensure!' do
    it 'does not raise error if key is set' do
      config.set(:key, :value)
      expect { config.ensure!(:key) }.to_not raise_error
    end

    it 'raises an error if key is not set' do
      expect { config.ensure!(:key) }.to raise_error(SystemExit)
    end
  end

  describe Mina::Configuration::DSL do
    let(:host_class) { Class.new { include Mina::Configuration::DSL } }
    let(:host) { host_class.new }

    [:fetch, :set].each do |method|
      it "should respond to #{method}" do
        expect(host).to respond_to(method)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mina-1.2.4 spec/lib/mina/configuration_spec.rb
mina-1.2.3 spec/lib/mina/configuration_spec.rb
mina-1.2.2 spec/lib/mina/configuration_spec.rb
mina-1.2.1 spec/lib/mina/configuration_spec.rb
mina-1.2.0 spec/lib/mina/configuration_spec.rb
mina-1.1.1 spec/lib/mina/configuration_spec.rb
mina-1.1.0 spec/lib/mina/configuration_spec.rb
mina-1.0.7 spec/lib/mina/configuration_spec.rb
mina-1.0.6 spec/lib/mina/configuration_spec.rb
mina-1.0.5 spec/lib/mina/configuration_spec.rb
mina-1.0.4 spec/lib/mina/configuration_spec.rb
mina-1.0.3 spec/lib/mina/configuration_spec.rb
mina-1.0.2 spec/lib/mina/configuration_spec.rb
mina-1.0.0 spec/lib/mina/configuration_spec.rb
mina-1.0.0.rc2 spec/lib/mina/configuration_spec.rb
mina-1.0.0.beta5 spec/lib/mina/configuration_spec.rb
mina-1.0.0.beta4 spec/lib/mina/configuration_spec.rb
mina-1.0.0.beta3 spec/lib/mina/configuration_spec.rb