Sha256: 3501ae72b8c1328078945148dab1365d40fcbce1b62161058300ec7f9e749f4a

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

require 'pathname'
require 'tmpdir'
require_relative '../spec_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')
          tempdir = Dir.mktmpdir
          ENV['XDG_DATA_HOME'] = tempdir
          path = "#{tempdir}/signore/signatures.yml"
          Settings.new.repo_path.must_equal Pathname.new(path)
        ensure
          FileUtils.rmtree tempdir
          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

1 entries across 1 versions & 1 rubygems

Version Path
signore-0.3.2 spec/signore/settings_spec.rb