Sha256: dc1e6acca466d04797a4c04c0ee7ad8929ebb65bb30f42efea34d487996b5531

Contents?: true

Size: 1.62 KB

Versions: 17

Compression:

Stored size: 1.62 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::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

17 entries across 17 versions & 1 rubygems

Version Path
mutant-0.9.8 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.7 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.6 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.5 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.4 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.3 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.2 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.1 spec/unit/mutant/expression/methods_spec.rb
mutant-0.9.0 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.24 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.23 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.22 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.21 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.20 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.19 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.18 spec/unit/mutant/expression/methods_spec.rb
mutant-0.8.17 spec/unit/mutant/expression/methods_spec.rb