
* I do not use 1.9.3 * Also keeping them in each file increases mental overhead (true it *can* be autoamted) * None of the files encodes NON ASCII chars. * I do not expect it makes any difference, since nobody programmatically will consume strings generated by mutant under the assumption they are UTF-8 encoded. * 1.9.3 Users have to deal with the encoding fuckup under ruby anyways.
47 lines
1.5 KiB
Ruby
47 lines
1.5 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Mutant::Matcher::Namespace do
|
|
let(:object) { described_class.new(cache, 'TestApp::Literal') }
|
|
let(:yields) { [] }
|
|
|
|
let(:cache) { Mutant::Cache.new }
|
|
|
|
subject { object.each { |item| yields << item } }
|
|
|
|
describe '#each' do
|
|
|
|
let(:singleton_a) { double('SingletonA', name: 'TestApp::Literal') }
|
|
let(:singleton_b) { double('SingletonB', name: 'TestApp::Foo') }
|
|
let(:singleton_c) { double('SingletonC', name: 'TestApp::LiteralOther') }
|
|
let(:subject_a) { double('SubjectA') }
|
|
let(:subject_b) { double('SubjectB') }
|
|
|
|
before do
|
|
Mutant::Matcher::Methods::Singleton.stub(:each)
|
|
.with(cache, singleton_a)
|
|
.and_yield(subject_a)
|
|
Mutant::Matcher::Methods::Instance.stub(:each)
|
|
.with(cache, singleton_a)
|
|
.and_yield(subject_b)
|
|
ObjectSpace.stub(each_object: [singleton_a, singleton_b, singleton_c])
|
|
end
|
|
|
|
context 'with no block' do
|
|
subject { object.each }
|
|
|
|
it { should be_instance_of(to_enum.class) }
|
|
|
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
|
skip 'FIX RBX rspec? BUG HERE'
|
|
else
|
|
it 'yields the expected values' do
|
|
expect(subject.to_a).to eql(object.to_a)
|
|
end
|
|
end
|
|
end
|
|
|
|
it 'should yield subjects' do
|
|
expect { subject }.to change { yields }.from([]).to([subject_a, subject_b])
|
|
end
|
|
end
|
|
end
|