Sha256: 356e10dcf95688a9487be5a10f2a13b3bd77f4ba73fcc70b10925dd20a0c117f

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

RSpec.describe Mutant::Env do
  let(:config) { Mutant::Config::DEFAULT.update(jobs: 1, reporter: Mutant::Reporter::Trace.new) }

  context '.new' do
    subject { described_class.new(config) }

    context 'when Module#name calls result in exceptions' do
      it 'warns via reporter' do
        klass = Class.new do
          def self.name
            raise
          end
        end

        expected_warnings = ["Class#name from: #{klass} raised an error: RuntimeError. #{Mutant::Env::SEMANTICS_MESSAGE}"]

        expect { subject }.to change { config.reporter.warn_calls }.from([]).to(expected_warnings)

        # Fix Class#name so other specs do not see this one
        class << klass
          undef :name
          def name
          end
        end
      end
    end

    context 'when Module#name does not return a String or nil' do
      it 'warns via reporter' do
        klass = Class.new do
          def self.name
            Object
          end
        end

        expected_warnings = ["Class#name from: #{klass.inspect} returned Object. #{Mutant::Env::SEMANTICS_MESSAGE}"]

        expect { subject }.to change { config.reporter.warn_calls }.from([]).to(expected_warnings)

        # Fix Class#name so other specs do not see this one
        class << klass
          undef :name
          def name
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mutant-0.7.3 spec/unit/mutant/env_spec.rb
mutant-0.7.2 spec/unit/mutant/env_spec.rb
mutant-0.7.1 spec/unit/mutant/env_spec.rb