free_mutant/spec/unit/mutant/context_spec.rb
Markus Schirp a0216cb6fa Bump ruby requirement to 2.1
* Use %i style symbol literal arrays
* Fix style
* Whitelist some preferred style
2015-05-31 21:20:54 +00:00

57 lines
1.2 KiB
Ruby

# rubocop:disable ClosingParenthesisIndentation
RSpec.describe Mutant::Context::Scope do
describe '.wrap' do
subject { described_class.wrap(scope, node) }
let(:node) { s(:str, 'test') }
context 'with Module as scope' do
let(:scope) { Mutant }
let(:expected) do
s(:module,
s(:const, nil, :Mutant),
s(:str, 'test')
)
end
it { should eql(expected) }
end
context 'with Class as scope' do
let(:scope) { Mutant::Context }
let(:expected) do
s(:class,
s(:const, nil, :Context),
nil,
s(:str, 'test')
)
end
it { should eql(expected) }
end
context 'with Class as scope' do
let(:scope) { Mutant::Context }
let(:expected) do
s(:class,
s(:const, nil, :Context),
nil,
s(:str, 'test')
)
end
it { should eql(expected) }
end
context 'with anything else as scope' do
let(:scope) { double(name: 'Foo') }
it 'raises exception' do
expect { subject }.to raise_error(RuntimeError, "Cannot wrap scope: #{scope.inspect}")
end
end
end
end