Sha256: f3d98da4cafa9a57ee9b2a12156b4c478d803f7b6a829c36fcc617233b99e934

Contents?: true

Size: 1.49 KB

Versions: 23

Compression:

Stored size: 1.49 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Mutant::CLI::Classifier::Namespace::Recursive, '#each' do
  let(:object)            { described_class.run(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

23 entries across 23 versions & 1 rubygems

Version Path
mutant-0.5.17 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.16 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.15 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.14 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.13 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.12 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.11 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.10 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.9 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.8 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.7 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.6 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.5 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.4 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.3 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.2 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.1 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.5.0 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.3.6 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
mutant-0.3.5 spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb