Sha256: 30b709ffd76b87f4b76e9d958c20ceb18f1839420375650c09eb05362c1e786d

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Mutant::Expression::Namespace::Recursive do

  let(:object) { described_class.parse(input) }
  let(:cache)  { Mutant::Cache.new            }
  let(:input)  { 'TestApp::Literal*'          }

  describe '#matcher' do
    subject { object.matcher(cache) }
    it { should eql(Mutant::Matcher::Namespace.new(cache, 'TestApp::Literal')) }
  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 a longer prefix' do
      let(:other) { described_class.parse('TestApp::Literal::Deep') }

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mutant-0.5.23 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.5.22 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.5.21 spec/unit/mutant/expression/namespace/recursive_spec.rb
mutant-0.5.20 spec/unit/mutant/expression/namespace/recursive_spec.rb