2014-08-10 17:04:05 -04:00
|
|
|
RSpec.describe Mutant::Isolation::None do
|
2014-07-05 22:11:31 -04:00
|
|
|
before do
|
|
|
|
@initial = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.run' do
|
|
|
|
let(:object) { described_class }
|
|
|
|
|
|
|
|
it 'does not isolate side effects' do
|
|
|
|
object.call { @initial = 2 }
|
|
|
|
expect(@initial).to be(2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'return block value' do
|
|
|
|
expect(object.call { :foo }).to be(:foo)
|
|
|
|
end
|
|
|
|
|
2014-07-05 23:12:44 -04:00
|
|
|
it 'wraps *all* exceptions' do
|
|
|
|
expect { object.call { fail } }.to raise_error(Mutant::Isolation::Error)
|
|
|
|
end
|
|
|
|
|
2014-07-05 22:11:31 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-08-10 17:04:05 -04:00
|
|
|
RSpec.describe Mutant::Isolation::Fork do
|
2014-07-05 22:11:31 -04:00
|
|
|
before do
|
|
|
|
@initial = 1
|
|
|
|
end
|
|
|
|
|
2014-06-24 20:13:24 -04:00
|
|
|
describe '.run' do
|
2014-06-08 13:55:13 -04:00
|
|
|
let(:object) { described_class }
|
|
|
|
|
2014-07-05 22:11:31 -04:00
|
|
|
it 'does isolate side effects' do
|
|
|
|
object.call { @initial = 2 }
|
|
|
|
expect(@initial).to be(1)
|
2014-06-09 11:36:00 -04:00
|
|
|
end
|
|
|
|
|
2014-06-24 20:13:24 -04:00
|
|
|
it 'return block value' do
|
|
|
|
expect(object.call { :foo }).to be(:foo)
|
2014-06-08 13:55:13 -04:00
|
|
|
end
|
|
|
|
|
2014-07-05 23:12:44 -04:00
|
|
|
it 'wraps Parallel::DeadWorker exceptions' do
|
|
|
|
expect { object.call { fail Parallel::DeadWorker } }.to raise_error(Mutant::Isolation::Error)
|
|
|
|
end
|
|
|
|
|
2014-10-17 17:51:36 -04:00
|
|
|
it 'wraps Parallel::DeadWorker exceptions caused by crashing ruby' do
|
|
|
|
expect do
|
|
|
|
object.call do
|
|
|
|
# Silence rb_bug writes
|
|
|
|
$stderr.reopen(File.open('/dev/null', 'w'))
|
|
|
|
fail RbBug.call
|
|
|
|
end
|
|
|
|
end.to raise_error(Mutant::Isolation::Error)
|
|
|
|
end
|
|
|
|
|
2014-06-08 13:55:13 -04:00
|
|
|
end
|
|
|
|
end
|