Sha256: 7b74a830b68ac4bf7be9d9fd4b2627dc24c03636d01ce1c95b6f72265b2b97b0

Contents?: true

Size: 1.59 KB

Versions: 9

Compression:

Stored size: 1.59 KB

Contents

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::Methods::Instance.new(TestApp::Literal)) }
    end

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

      it { should eql(Mutant::Matcher::Methods::Singleton.new(TestApp::Literal)) }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mutant-0.8.16 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.15 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.14 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.13 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.12 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.11 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.10 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.9 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.8 spec/unit/mutant/expression/methods_spec.rb