1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
# This is the only file the plugin should require
require 'guard/compat/test/helper'
require 'guard/compat/example'
RSpec.describe Guard::MyPlugin, exclude_stubs: [Guard::Plugin] do
let(:options) { { foo: :bar } }
subject { described_class.new(options) }
before do
meths = %w(info warning error deprecation debug notify color color_enabled?)
meths.each do |type|
allow(Guard::Compat::UI).to receive(type.to_sym)
end
end
it 'passes options' do
expect(subject.options).to include(foo: :bar)
end
it 'works without options' do
expect { described_class.new }.to_not raise_error
end
describe '#start' do
before { subject.start }
%w(info warning error deprecation debug notify).each do |type|
specify do
expect(Guard::Compat::UI).to have_received(type.to_sym).with('foo')
end
end
end
describe '#run_all' do
before { subject.run_all }
%w(info warning error deprecation debug notify).each do |type|
specify do
expect(Guard::Compat::UI).to have_received(type.to_sym)
.with('foo', bar: :baz)
end
end
end
describe '#run_on_modifications' do
before do
allow(Guard::Compat).to receive(:matching_files)
allow(Guard::Compat).to receive(:watched_directories)
end
before { subject.run_on_modifications }
specify { expect(Guard::Compat::UI).to have_received(:color_enabled?) }
specify { expect(Guard::Compat).to have_received(:matching_files) }
end
end
|