Sha256: 574923fa425bbc1c6155a67713a28c0d6e5b19f34366c6a5fe49581539b0a11c

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

require 'rspec'
require 'devinstall'

describe 'Settings' do

  it 'should load an existig file' do
    expect(@config.load!('./spec/assets/example_02.yml')).to be_true
  end

  it 'should not load an unexisting file' do
    expect(@config.load!('doc/unexisting.yml')).to be_false
  end

  it 'should load at init' do
    expect(@config).to be_an_instance_of(Devinstall::Settings)
    [:defaults, :local, :build, :install, :tests, :repos].each do |p|
      expect(@config.respond_to? p).to be_true
    end # all sections loaded!
  end

  it 'should have a method defaults' do
    expect(@config.respond_to? :defaults).to be_true
  end

  it 'the method "defaults" should have only one argument' do
    expect(@config.defaults(:type)).to eq 'deb'
  end

  it 'should instantiate a new "Action" when hashes are given' do
    expect(@config.build(type: 'deb', env: 'dev', pkg: @package)).to be_an_instance_of(Devinstall::Settings::Action)
  end

  it 'should instantiata a new "Action" when partial hashes are given' do
    expect(@config.build(pkg: @package)).to be_an_instance_of(Devinstall::Settings::Action)
  end

  it 'should raise "UnknownKeys" errors for unknown keys' do
    expect { @config.defaults :none }.to raise_error(Devinstall::UnknownKeyError)
  end

  it 'should raise "KeyNotDefinedError" errors for undefined keys' do
    expect { @config.tests(:provider, pkg: @package) }.to raise_error(Devinstall::KeyNotDefinedError)
  end

  it 'should produce a value if all arguments are valid' do
    expect(@config.build(:command, pkg: @package)).to eq('cd %f/%p && dpkg-buildpackage')
  end

  describe 'Action' do
    it 'should have a [] method' do
      rr=@config.build(pkg: @package, type: @type, env: @env)
      expect(rr[:target]).to eq('rs')
    end

    it 'should enumerate all defined values' do
      ar=[]
      @config.build(pkg: @package, type: @type, env: @env).each { |k, _| ar << k }
      expect(ar.sort == [:folder, :command, :provider, :type, :arch, :target].sort).to be_true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devinstall-1.2.2 spec/support/01_settings_spec.rb