Sha256: d3e0eb36c1adbbc1510b654d1dff792620d4ad64497761b2dc73b6eddd82e35f

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

RSpec.describe Mutant::Subject::Method::Singleton do

  let(:object)  { described_class.new(context, node) }
  let(:node)    { s(:defs, s(:self), :foo, s(:args)) }

  let(:context) do
    Mutant::Context.new(scope, instance_double(Pathname))
  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 { should eql(parse_expression('Test.foo')) }

    it_should_behave_like 'an idempotent method'
  end

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

    it { should 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 { should eql("def self.foo\nend") }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mutant-0.8.13 spec/unit/mutant/subject/method/singleton_spec.rb
mutant-0.8.12 spec/unit/mutant/subject/method/singleton_spec.rb
mutant-0.8.11 spec/unit/mutant/subject/method/singleton_spec.rb
mutant-0.8.10 spec/unit/mutant/subject/method/singleton_spec.rb