Sha256: 94453e1ad3396d06bbede3e8711124335de09a6ed9dfd3724f59d1b0b1a6786b

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Mutant::CLI::Classifier::Namespace::Recursive, '#each' do
  let(:object)            { described_class.build(cache, "#{input}*") }
  let(:cache)             { Mutant::Cache.new                         }
  let(:known_namespace)   { '::TestApp::Literal'                      }
  let(:unknown_namespace) { '::TestApp::Object'                       }

  context 'with a block' do
    subject { object.each {} }

    context 'with a known namespace' do
      let(:input) { known_namespace }

      it_behaves_like 'a command method'

      it 'yield method subjects' do
        expect { |block| object.each(&block) }
          .to yield_control.exactly(7).times
      end
    end

    context 'with an unknown namespace' do
      let(:input) { unknown_namespace }

      it 'raises an exception' do
        expect { subject }.to raise_error(NameError)
      end
    end
  end

  context 'without a block' do
   subject { object.each }

    context 'with a known namespace' do
      let(:input) { known_namespace }

      it 'returns an enumerator' do
        should be_instance_of(to_enum.class)
      end

      it 'yield an instance subject' do
        expect { |block| object.each(&block) }
          .to yield_control.exactly(7).times
      end
    end

    context 'with an unknown namespace' do
      let(:input) { unknown_namespace }

      it 'raises an exception when #each is called' do
        expect { subject.each {} }.to raise_error(NameError)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.3.0.rc1 spec/unit/mutant/cli/classifier/namespace/recursive/each_spec.rb
mutant-0.3.0.beta22 spec/unit/mutant/cli/classifier/namespace/recursive/each_spec.rb