Sha256: 13d01c5ade936196aa150534129166e95a51f3c4e6a8b71825cca085076b613d

Contents?: true

Size: 1.6 KB

Versions: 15

Compression:

Stored size: 1.6 KB

Contents

RSpec.describe Mutant::Expression::Namespace::Recursive do

  let(:object) { described_class.parse(input) }
  let(:input)  { 'TestApp::Literal*'          }
  let(:env)    { Fixtures::TEST_ENV           }

  describe '#matcher' do
    subject { object.matcher(env) }

    it { should eql(Mutant::Matcher::Namespace.new(env, object)) }
  end

  describe '#match_length' do
    subject { object.match_length(other) }

    context 'when other is an equivalent expression' do
      let(:other) { described_class.parse(object.syntax) }

      it { should be(0) }
    end

    context 'when other expression describes a shorter prefix' do
      let(:other) { described_class.parse('TestApp') }

      it { should be(0) }
    end

    context 'when other expression describes adjacent namespace' do
      let(:other) { described_class.parse('TestApp::LiteralFoo') }

      it { should be(0) }
    end

    context 'when other expression describes root namespace' do
      let(:other) { described_class.parse('TestApp::Literal') }

      it { should be(16) }
    end

    context 'when other expression describes a longer prefix' do
      context 'on constants' do
        let(:other) { described_class.parse('TestApp::Literal::Deep') }

        it { should be(input[0..-2].length) }
      end

      context 'on singleton method' do
        let(:other) { described_class.parse('TestApp::Literal.foo') }

        it { should be(input[0..-2].length) }
      end

      context 'on instance method' do
        let(:other) { described_class.parse('TestApp::Literal#foo') }

        it { should be(input[0..-2].length) }
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mutant-0.8.0 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.7.9 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.7.8 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.7.7 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.7.6 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.7.5 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.7.4 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.7.3 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.7.2 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.7.1 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.6.7 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.6.6 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.6.5 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.6.4 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.6.3 spec/unit/mutant/expression/namespace/recursive_spec.rb