2019-08-22 10:57:44 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-13 11:21:12 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-06-08 15:10:00 +00:00
|
|
|
RSpec.describe SystemCheck, :silence_stdout do
|
2020-05-19 15:08:04 +00:00
|
|
|
before do
|
|
|
|
stub_const('SimpleCheck', Class.new(SystemCheck::BaseCheck))
|
|
|
|
stub_const('OtherCheck', Class.new(SystemCheck::BaseCheck))
|
|
|
|
|
|
|
|
SimpleCheck.class_eval do
|
|
|
|
def check?
|
|
|
|
true
|
|
|
|
end
|
2017-05-31 18:45:00 +00:00
|
|
|
end
|
|
|
|
|
2020-05-19 15:08:04 +00:00
|
|
|
OtherCheck.class_eval do
|
|
|
|
def check?
|
|
|
|
false
|
|
|
|
end
|
2017-05-31 18:45:00 +00:00
|
|
|
end
|
2017-05-25 23:46:54 +00:00
|
|
|
end
|
|
|
|
|
2017-02-13 11:21:12 +00:00
|
|
|
describe '.run' do
|
2017-07-25 17:09:00 +00:00
|
|
|
subject { described_class }
|
2017-02-13 11:21:12 +00:00
|
|
|
|
2017-05-31 18:45:00 +00:00
|
|
|
it 'detects execution of SimpleCheck' do
|
|
|
|
is_expected.to execute_check(SimpleCheck)
|
2017-02-13 11:21:12 +00:00
|
|
|
|
2017-05-31 18:45:00 +00:00
|
|
|
subject.run('Test', [SimpleCheck])
|
|
|
|
end
|
2017-02-13 11:21:12 +00:00
|
|
|
|
2017-05-31 18:45:00 +00:00
|
|
|
it 'detects exclusion of OtherCheck in execution' do
|
|
|
|
is_expected.not_to execute_check(OtherCheck)
|
2017-02-13 11:21:12 +00:00
|
|
|
|
2017-05-31 18:45:00 +00:00
|
|
|
subject.run('Test', [SimpleCheck])
|
2017-02-13 11:21:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|