Sha256: 0cf76e2f6bbd103553facdbc445fecd038a5b5566b044b9078bb66e4877c44ba

Contents?: true

Size: 809 Bytes

Versions: 11

Compression:

Stored size: 809 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  subject(:editor) { object.new(file) }

  before { allow(object).to receive(:command).and_return(name) }

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

    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 { allow(TTY::System).to receive(:unix?).and_return(true) }

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
tty-0.5.0 spec/tty/system/editor/build_spec.rb
tty-0.4.0 spec/tty/system/editor/build_spec.rb
tty-0.3.2 spec/tty/system/editor/build_spec.rb
tty-0.3.1 spec/tty/system/editor/build_spec.rb
tty-0.3.0 spec/tty/system/editor/build_spec.rb
tty-0.2.1 spec/tty/system/editor/build_spec.rb
tty-0.2.0 spec/tty/system/editor/build_spec.rb
tty-0.1.3 spec/tty/system/editor/build_spec.rb
tty-0.1.2 spec/tty/system/editor/build_spec.rb
tty-0.1.1 spec/tty/system/editor/build_spec.rb
tty-0.1.0 spec/tty/system/editor/build_spec.rb