Add specs for Subject#tests
This commit is contained in:
parent
84b259ab6a
commit
88fe09ed92
1 changed files with 56 additions and 2 deletions
|
@ -2,7 +2,11 @@ RSpec.describe Mutant::Subject do
|
|||
let(:class_under_test) do
|
||||
Class.new(described_class) do
|
||||
def expression
|
||||
Mutant::Expression.parse('Test')
|
||||
Mutant::Expression.parse('SubjectA')
|
||||
end
|
||||
|
||||
def match_expressions
|
||||
[expression] << Mutant::Expression.parse('SubjectB')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -34,7 +38,7 @@ RSpec.describe Mutant::Subject do
|
|||
describe '#identification' do
|
||||
subject { object.identification }
|
||||
|
||||
it { should eql('Test:source_path:source_line') }
|
||||
it { should eql('SubjectA:source_path:source_line') }
|
||||
end
|
||||
|
||||
describe '#prepare' do
|
||||
|
@ -43,6 +47,56 @@ RSpec.describe Mutant::Subject do
|
|||
it_should_behave_like 'a command method'
|
||||
end
|
||||
|
||||
describe '#tests' do
|
||||
let(:config) { Mutant::Config::DEFAULT.update(integration: integration) }
|
||||
let(:integration) { double('Integration', all_tests: all_tests) }
|
||||
let(:test_a) { double('test', expression: Mutant::Expression.parse('SubjectA')) }
|
||||
let(:test_b) { double('test', expression: Mutant::Expression.parse('SubjectB')) }
|
||||
let(:test_c) { double('test', expression: Mutant::Expression.parse('SubjectC')) }
|
||||
|
||||
subject { object.tests }
|
||||
|
||||
context 'without available tests' do
|
||||
let(:all_tests) { [] }
|
||||
|
||||
it { should eql([]) }
|
||||
|
||||
it_should_behave_like 'an idempotent method'
|
||||
end
|
||||
|
||||
context 'without qualifying tests' do
|
||||
let(:all_tests) { [test_c] }
|
||||
|
||||
it { should eql([]) }
|
||||
|
||||
it_should_behave_like 'an idempotent method'
|
||||
end
|
||||
|
||||
context 'with qualifying tests for first match expression' do
|
||||
let(:all_tests) { [test_a] }
|
||||
|
||||
it { should eql([test_a]) }
|
||||
|
||||
it_should_behave_like 'an idempotent method'
|
||||
end
|
||||
|
||||
context 'with qualifying tests for second match expression' do
|
||||
let(:all_tests) { [test_b] }
|
||||
|
||||
it { should eql([test_b]) }
|
||||
|
||||
it_should_behave_like 'an idempotent method'
|
||||
end
|
||||
|
||||
context 'with qualifying tests for the first and second match expression' do
|
||||
let(:all_tests) { [test_a, test_b] }
|
||||
|
||||
it { should eql([test_a]) }
|
||||
|
||||
it_should_behave_like 'an idempotent method'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#node' do
|
||||
subject { object.node }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue