Sha256: 60cc5e6c1f1690b9b160010c24b0bbfd82bd5c8bb4732612d25a24fa8002dc3b

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

RSpec.describe Mutest::Subject::Method::Instance do
  let(:object)  { described_class.new(context, node) }

  let(:context) do
    Mutest::Context.new(scope, instance_double(Mutest::SourceFile))
  end

  let(:node) do
    s(:def, :foo, s(:args))
  end

  let(:scope) do
    Class.new do
      attr_reader :bar

      def initialize
        @bar = :boo
      end

      def foo
      end

      def self.name
        'Test'
      end
    end
  end

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

    it { is_expected.to eql(parse_expression('Test#foo')) }

    it_behaves_like 'an idempotent method'
  end

  describe '#match_expression' do
    subject { object.match_expressions }

    it { is_expected.to eql(%w[Test#foo Test*].map(&method(:parse_expression))) }

    it_behaves_like 'an idempotent method'
  end

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

    let(:context) do
      Mutest::Context.new(scope, instance_double(Mutest::SourceFile))
    end

    it 'undefines method on scope' do
      expect { subject }.to change { scope.instance_methods.include?(:foo) }.from(true).to(false)
    end

    it_behaves_like 'a command method'
  end

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

    it { is_expected.to eql("def foo\nend") }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mutest-0.0.10 spec/unit/mutest/subject/method/instance_spec.rb
mutest-0.0.9 spec/unit/mutest/subject/method/instance_spec.rb
mutest-0.0.8 spec/unit/mutest/subject/method/instance_spec.rb
mutest-0.0.7 spec/unit/mutest/subject/method/instance_spec.rb