Sha256: 26ce1cb1c786e6b7f61feca3310cf68c78072ab3a9dda62b670774ba43f95cdc

Contents?: true

Size: 1.88 KB

Versions: 12

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

RSpec.describe Mutant::Subject do
  let(:class_under_test) do
    Class.new(described_class) do
      def expression
        Mutant::Expression::Namespace::Exact.new(scope_name: 'SubjectA')
      end

      def match_expressions
        [
          expression,
          Mutant::Expression::Namespace::Exact.new(scope_name: 'SubjectB')
        ]
      end
    end
  end

  let(:object) do
    class_under_test.new(
      context:  context,
      node:     node,
      warnings: warnings
    )
  end

  let(:node) do
    Unparser.parse(<<-RUBY)
      def foo
      end
    RUBY
  end

  let(:context) do
    double(
      'Context',
      source_path: 'source_path'
    )
  end

  let(:warnings) { instance_double(Mutant::Warnings) }

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

    it { should eql('SubjectA:source_path:1') }
  end

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

    it { should be(1) }
  end

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

    it { should eql(1..2) }
  end

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

    it_should_behave_like 'a command method'
  end

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

    it { should be(node) }

    it_should_behave_like 'an idempotent method'
  end

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

    before do
      expect(Mutant::Mutator).to receive(:mutate).with(node).and_return([mutation_a, mutation_b])
    end

    let(:mutation_a) { instance_double(Parser::AST::Node, :mutation_a) }
    let(:mutation_b) { instance_double(Parser::AST::Node, :mutation_b) }

    it 'generates neutral and evil mutations' do
      should eql([
        Mutant::Mutation::Neutral.new(object, node),
        Mutant::Mutation::Evil.new(object, mutation_a),
        Mutant::Mutation::Evil.new(object, mutation_b)
      ])
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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