Sha256: 5cebc2c196327b01d0fe497b1c669279cfb8583e73ba5e254a8b1686d69d85e7

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

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

7 entries across 7 versions & 1 rubygems

Version Path
mutant-0.5.26 spec/unit/mutant/expression/method_spec.rb
mutant-0.5.25 spec/unit/mutant/expression/method_spec.rb
mutant-0.5.24 spec/unit/mutant/expression/method_spec.rb
mutant-0.5.23 spec/unit/mutant/expression/method_spec.rb
mutant-0.5.22 spec/unit/mutant/expression/method_spec.rb
mutant-0.5.21 spec/unit/mutant/expression/method_spec.rb
mutant-0.5.20 spec/unit/mutant/expression/method_spec.rb