Sha256: 73ba399d0d521ee4835292f73e93e14dc170dc98045afa101742890b3be876e2
Contents?: true
Size: 1.9 KB
Versions: 2
Compression:
Stored size: 1.9 KB
Contents
require 'spec_helper' describe Phare::CheckSuite do let(:described_class) { Phare::CheckSuite } describe :run do let(:options) { { directory: '.' } } let(:suite) { described_class.new(options) } before do Phare::CheckSuite::DEFAULT_CHECKS.values.each_with_index do |check, index| exit_status = exit_status_proc.call(index) allow_any_instance_of(check).to receive(:run) allow_any_instance_of(check).to receive(:status).and_return(exit_status) end end context 'with a single failing check' do let(:exit_status_proc) do proc { |index| index == 2 ? 1337 : 0 } end it { expect { suite.run }.to change { suite.status }.to(1337) } end context 'with a multiple failing checks' do let(:exit_status_proc) do proc { |index| (index * 500) + 20 } end it { expect { suite.run }.to change { suite.status }.to(20) } end context 'with no failing check' do let(:exit_status_proc) { proc { 0 } } it { expect { suite.run }.to change { suite.status }.to(0) } end end describe :checks do let(:options) { { directory: '.', skip: skip, only: only } } let(:suite) { described_class.new(options) } let(:skip) { [] } let(:only) { [] } context 'with "only" option' do let(:only) { [:rubocop, :foo, :eslint] } it { expect(suite.checks).to eql [:rubocop, :eslint] } end context 'with "skip" option' do let(:skip) { [:stylelint, :foo] } it { expect(suite.checks).to eql [:rubocop, :eslint] } end context 'with both "only" and "skip" option' do let(:skip) { [:stylelint, :rubocop] } let(:only) { [:stylelint, :foo, :eslint] } it { expect(suite.checks).to eql [:stylelint, :eslint] } end context 'with both "only" and "skip" option' do it { expect(suite.checks).to eql Phare::CheckSuite::DEFAULT_CHECKS.keys } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
phare-1.0.1 | spec/phare/check_suite_spec.rb |
phare-1.0.0 | spec/phare/check_suite_spec.rb |