Sha256: 4854473a0f0786c813daf3f0c48ea3d7e9cc66b2c00668385f4ea8f8d45c9533

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

RSpec.describe Mutest::Subject::Method::Singleton do
  let(:object)  { described_class.new(context, node) }
  let(:node)    { s(:defs, s(:self), :foo, s(:args)) }

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

  let(:scope) do
    Class.new do
      def self.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_should_behave_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_should_behave_like 'an idempotent method'
  end

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

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

    it_should_behave_like 'a command method'
  end

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mutest-0.0.6 spec/unit/mutest/subject/method/singleton_spec.rb
mutest-0.0.5 spec/unit/mutest/subject/method/singleton_spec.rb
mutest-0.0.4 spec/unit/mutest/subject/method/singleton_spec.rb
mutest-0.0.3 spec/unit/mutest/subject/method/singleton_spec.rb
mutest-0.0.2 spec/unit/mutest/subject/method/singleton_spec.rb