Sha256: a946d467852843f864ec609b25777118e594adc147fb5b5f546f98af73a23a7c

Contents?: true

Size: 1.01 KB

Versions: 27

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'fedux_org_stdlib/editor'

RSpec.describe FeduxOrgStdlib::Editor do
  around :example do |example|
    with_env 'PATH' => absolute_path('.') do
      example.run
    end
  end

  context '#path' do
    let(:editor) { Editor.new }

    Editor.new.known_commands.each do |c|
      it "finds editor #{c}" do
        touch_file c
        filesystem_permissions '0755', c
        expect(editor.path).to eq absolute_path(c)
      end
    end

    it 'changes search path' do
      touch_file 'vim'
      filesystem_permissions '0755', 'vim'

      editor = Editor.new search_paths: absolute_path('.')
      expect(editor.path).to eq absolute_path('vim')
    end

    it 'changes default editors' do
      touch_file 'vi'
      filesystem_permissions '0755', 'vi'

      editor = Editor.new editors: %w(vi)
      expect(editor.path).to eq absolute_path('vi')
    end

    it 'returns nil if no editor can be found' do
      editor = Editor.new
      expect(editor.path).to be nil
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.11.18 spec/editor_spec.rb
fedux_org-stdlib-0.11.17 spec/editor_spec.rb
fedux_org-stdlib-0.11.16 spec/editor_spec.rb
fedux_org-stdlib-0.11.15 spec/editor_spec.rb
fedux_org-stdlib-0.11.14 spec/editor_spec.rb
fedux_org-stdlib-0.11.12 spec/editor_spec.rb
fedux_org-stdlib-0.11.11 spec/editor_spec.rb
fedux_org-stdlib-0.11.9 spec/editor_spec.rb
fedux_org-stdlib-0.11.8 spec/editor_spec.rb
fedux_org-stdlib-0.11.7 spec/editor_spec.rb
fedux_org-stdlib-0.11.6 spec/editor_spec.rb
fedux_org-stdlib-0.11.5 spec/editor_spec.rb
fedux_org-stdlib-0.11.4 spec/editor_spec.rb
fedux_org-stdlib-0.11.3 spec/editor_spec.rb
fedux_org-stdlib-0.11.2 spec/editor_spec.rb
fedux_org-stdlib-0.11.1 spec/editor_spec.rb
fedux_org-stdlib-0.11.0 spec/editor_spec.rb
fedux_org-stdlib-0.10.9 spec/editor_spec.rb
fedux_org-stdlib-0.10.8 spec/editor_spec.rb
fedux_org-stdlib-0.10.7 spec/editor_spec.rb