# 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