Sha256: 8a4834705f69c2cf27b0eeae9df06ec60b33301f0cc4eb699f6e1ca22e506476

Contents?: true

Size: 1.78 KB

Versions: 3

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

RSpec.describe Mutant::Expression::Methods do
  let(:object) { described_class.new(attributes) }

  describe '#match_length' do
    let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '#' } }

    subject { object.match_length(other) }

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

      it { should be(object.syntax.length) }
    end

    context 'when other is matched' do
      let(:other) { parse_expression('TestApp::Literal#foo') }

      it { should be(object.syntax.length) }
    end

    context 'when other is an not matched expression' do
      let(:other) { parse_expression('Foo*') }

      it { should be(0) }
    end
  end

  describe '#syntax' do
    subject { object.syntax }

    context 'with an instance method' do
      let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '#' } }

      it { should eql('TestApp::Literal#') }
    end

    context 'with a singleton method' do
      let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '.' } }

      it { should eql('TestApp::Literal.') }
    end
  end

  describe '#matcher' do
    subject { object.matcher }

    context 'with an instance method' do
      let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '#' } }

      it { should eql(Mutant::Matcher::Chain.new([Mutant::Matcher::Methods::Instance.new(TestApp::Literal)])) }
    end

    context 'with a singleton method' do
      let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '.' } }

      it do
        should eql(Mutant::Matcher::Chain.new([
          Mutant::Matcher::Methods::Singleton.new(TestApp::Literal),
          Mutant::Matcher::Methods::Metaclass.new(TestApp::Literal)
        ]))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mutant-0.9.11 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.10 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.9 spec/unit/mutant/expression/methods_spec.rb