Sha256: 60df34bb520eee8d3bab173605aaaf7f35fe14da85ef46bb91d2f9390cda3c91

Contents?: true

Size: 879 Bytes

Versions: 3

Compression:

Stored size: 879 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe TTY::Plugin, '#load!' do
  let(:gem)    { Gem::Specification.new('tty-console', '3.1.3')}

  it "loads a gem" do
    plugin = TTY::Plugin.new('tty-console', gem)
    allow(plugin).to receive(:require).with('tty-console').and_return(true)

    plugin.load!

    expect(plugin).to have_received(:require).once
  end

  it 'fails to load the gem' do
    plugin = TTY::Plugin.new('tty-console', gem)
    allow(plugin).to receive(:require) { raise LoadError }

    expect {
      plugin.load!
    }.to output(/Unable to load plugin tty-console./).to_stdout
  end

  it 'fails to require the gem' do
    plugin = TTY::Plugin.new('tty-console', gem)
    allow(plugin).to receive(:require) { raise StandardError }

    expect {
      plugin.load!
    }.to output(/require 'tty-console' failed with StandardError\n/).to_stdout
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-0.7.0 spec/tty/plugins/plugin/load_spec.rb
tty-0.6.1 spec/tty/plugins/plugin/load_spec.rb
tty-0.6.0 spec/tty/plugins/plugin/load_spec.rb