Sha256: b34f48d41fdc1323ea47637ea7245735eb80b10c5c5d16e5fadaea17b7dc5af3

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mutant-0.7.9 spec/unit/mutant/context_spec.rb
mutant-0.7.8 spec/unit/mutant/context_spec.rb
mutant-0.7.7 spec/unit/mutant/context_spec.rb
mutant-0.7.6 spec/unit/mutant/context_spec.rb
mutant-0.7.5 spec/unit/mutant/context_spec.rb
mutant-0.7.4 spec/unit/mutant/context_spec.rb
mutant-0.7.3 spec/unit/mutant/context_spec.rb
mutant-0.7.2 spec/unit/mutant/context_spec.rb
mutant-0.7.1 spec/unit/mutant/context_spec.rb
mutant-0.6.7 spec/unit/mutant/context_spec.rb