Sha256: 4cd247c7a8f02a7fdbf7c531b3aa87cc7c696239a6cacdb1a5bc08e2d1b24b2a

Contents?: true

Size: 1.48 KB

Versions: 12

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

RSpec.describe Mutant::Expression::Method do
  let(:object)           { parse_expression(input)   }
  let(:env)              { Fixtures::TEST_ENV        }
  let(:instance_method)  { 'TestApp::Literal#string' }
  let(:singleton_method) { 'TestApp::Literal.string' }

  describe '#match_length' do
    let(:input) { instance_method }

    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 an unequivalent expression' do
      let(:other) { parse_expression('Foo*') }

      it { should be(0) }
    end
  end

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

    context 'with an instance method' do
      let(:input) { instance_method }

      it 'returns correct matcher' do
        expect(subject.call(env).map(&:expression)).to eql([object])
      end
    end

    context 'with a singleton method' do
      let(:input) { singleton_method }

      it 'returns correct matcher' do
        expect(subject.call(env).map(&:expression)).to eql([object])
      end
    end
  end

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

    context 'on instance method' do
      let(:input) { instance_method }

      it { should eql(instance_method) }
    end

    context 'on singleton method' do
      let(:input) { singleton_method }

      it { should eql(singleton_method) }
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mutant-0.9.11 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.10 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.9 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.8 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.7 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.6 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.5 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.4 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.3 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.2 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.1 spec/unit/mutant/expression/method_spec.rb
mutant-0.9.0 spec/unit/mutant/expression/method_spec.rb