spec/mongo/collection/view/readable_spec.rb in mongo-2.0.2 vs spec/mongo/collection/view/readable_spec.rb in mongo-2.0.3
- old
+ new
@@ -434,16 +434,16 @@
end
end
describe '#projection' do
+ let(:options) do
+ { :projection => { 'x' => 1 } }
+ end
+
context 'when projection are specified' do
- let(:options) do
- { :projection => { 'x' => 1 } }
- end
-
let(:new_projection) do
{ 'y' => 1 }
end
it 'sets the projection' do
@@ -454,15 +454,26 @@
it 'returns a new View' do
expect(view.projection(new_projection)).not_to be(view)
end
end
- context 'when projection are not specified' do
+ context 'when projection is not specified' do
- let(:options) { { :projection => { 'x' => 1 } } }
-
it 'returns the projection' do
expect(view.projection).to eq(options[:projection])
+ end
+ end
+
+ context 'when projection is not a document' do
+
+ let(:new_projection) do
+ 'y'
+ end
+
+ it 'raises an error' do
+ expect do
+ view.projection(new_projection)
+ end.to raise_error(Mongo::Error::InvalidDocument)
end
end
end
describe '#read' do