Sha256: a3705924cf350cf75b2a9e5410ba4f7cda6969558eb665cdbc08cdebfe62fe2b

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Mutant::Expression::Method do

  let(:object)           { described_class.parse(input) }
  let(:cache)            { Mutant::Cache.new            }
  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) { described_class.parse(object.syntax) }

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

    context 'when other is an unequivalent expression' do
      let(:other) { described_class.parse('Foo*') }

      it { should be(0) }
    end
  end

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

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

      it 'returns correct matcher' do
        should eql(Mutant::Matcher::Method::Instance.new(
          cache,
          TestApp::Literal, TestApp::Literal.instance_method(:string)
        ))
      end
    end

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

      it { should eql(Mutant::Matcher::Method::Singleton.new(cache, TestApp::Literal, TestApp::Literal.method(:string))) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.5.19 spec/unit/mutant/expression/method_spec.rb
mutant-0.5.18 spec/unit/mutant/expression/method_spec.rb