Sha256: cfc6c70fc2e6ff5cce1a2399598a086bff3caa960d4ec6f70fd0e6f91823029d

Contents?: true

Size: 893 Bytes

Versions: 2

Compression:

Stored size: 893 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'spec_helper'

describe TTY::System::Editor, '#build' do
  let(:file) { "/users/piotr/hello world.rb" }
  let(:editor) { "vim" }
  let(:object) { described_class }

  subject { object.new(file) }

  before { object.stub(:command).and_return(editor) }

  context 'when on windows' do
    before {
      TTY::System.stub(:unix?).and_return(false)
      TTY::System.stub(:windows?).and_return(true)
    }

    after {
      TTY::System.unstub(:unix?)
      TTY::System.unstub(:windows?)
    }

    it "doesn't shell escape" do
      expect(subject.build).to eql("vim \\users\\piotr\\hello world.rb")
    end
  end

  context 'when on unix' do

    before { TTY::System.stub(:unix?).and_return(true) }

    after  { TTY::System.unstub(:unix?) }

    it 'escapes shell' do
      expect(subject.build).to eql("vim /users/piotr/hello\\ world.rb")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tty-0.0.11 spec/tty/system/editor/build_spec.rb
tty-0.0.10 spec/tty/system/editor/build_spec.rb