Sha256: 9ffa3990c8a230471211f597ea03f7c49b28d9066a082c65c697d5554e111878

Contents?: true

Size: 632 Bytes

Versions: 2

Compression:

Stored size: 632 Bytes

Contents

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

require 'spec_helper'

describe TTY::System::Editor, '#open' do
  let(:file) { "hello.rb" }

  subject { described_class }

  context 'when no editor' do
    before { subject.stub(:command).and_return(nil) }

    it 'raises error' do
      expect { subject.open(file) }.to raise_error(TTY::CommandInvocationError)
    end
  end

  context 'when editor'  do
    before { subject.stub(:command).and_return('vim') }

    it 'invokes editor' do
      invocable = double(:invocable, :invoke => nil)
      subject.should_receive(:new).with(file).and_return(invocable)
      subject.open(file)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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