Sha256: 3b155505463aec85e00bc99f1117a377e16bcaf68090037698ffebc5a1d35946

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

require 'pathname'
require 'tmpdir'
require_relative '../test_helper'
require_relative '../../lib/signore/settings'
require_relative '../../lib/signore/tags'

module Signore
  describe Settings do
    describe '#action' do
      it 'is defined by the first argument' do
        Settings.new(['prego']).action.must_equal 'prego'
      end
    end

    describe '#repo_path' do
      it 'honours XDG_DATA_HOME if it’s set' do
        begin
          old_xdg = ENV.delete('XDG_DATA_HOME')
          ENV['XDG_DATA_HOME'] = Dir.mktmpdir
          path = "#{ENV['XDG_DATA_HOME']}/signore/signatures.yml"
          Settings.new.repo_path.must_equal Pathname.new(path)
        ensure
          FileUtils.rmtree ENV['XDG_DATA_HOME']
          old_xdg ? ENV['XDG_DATA_HOME'] = old_xdg : ENV.delete('XDG_DATA_HOME')
        end
      end

      it 'defaults XDG_DATA_HOME to ~/.local/share if it’s not set' do
        begin
          old_xdg = ENV.delete('XDG_DATA_HOME')
          path    = File.expand_path('~/.local/share/signore/signatures.yml')
          Settings.new.repo_path.must_equal Pathname.new(path)
        ensure
          ENV['XDG_DATA_HOME'] = old_xdg if old_xdg
        end
      end
    end

    describe '#tags' do
      it 'returns the forbidden and required tags' do
        tags = Tags.new(forbidden: %w(tech), required: %w(en))
        Settings.new(%w(prego ~tech en)).tags.must_equal tags
      end

      it 'doesn’t blow up on empty args' do
        Settings.new([]).tags.must_equal Tags.new
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
signore-0.4.0 test/signore/settings_test.rb
signore-0.3.3 test/signore/settings_test.rb