Sha256: f2436dd7c211cebc7ed50ccf3600fedd009badc9bc2814ae8b17e90835bb2fec

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 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 '#db_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.db_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.db_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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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