spec/mongo/collection/view/readable_spec.rb in mongo-2.5.0.beta vs spec/mongo/collection/view/readable_spec.rb in mongo-2.5.0
- old
+ new
@@ -177,10 +177,28 @@
end
it_behaves_like 'a read concern aware operation'
end
+ context 'when a session supporting causal consistency is used' do
+
+ let(:view) do
+ Mongo::Collection::View.new(collection, selector, session: session)
+ end
+
+ let(:operation) do
+ begin; view.map_reduce(map, reduce).to_a; rescue; end
+ end
+
+ let(:command) do
+ operation
+ subscriber.started_events.find { |cmd| cmd.command_name == 'mapreduce' }.command
+ end
+
+ it_behaves_like 'an operation supporting causally consistent reads'
+ end
+
context 'when not iterating the map/reduce' do
it 'returns the map/reduce object' do
expect(map_reduce).to be_a(Mongo::Collection::View::MapReduce)
end
@@ -303,11 +321,11 @@
it 'returns the count of matching documents' do
expect(view.count).to eq(10)
end
end
- it 'takes a read preference option' do
+ it 'takes a read preference option', unless: sharded? do
expect(view.count(read: { mode: :secondary })).to eq(10)
end
context 'when a read preference is set on the view', unless: sharded? do
@@ -458,17 +476,17 @@
expect(result).to eq(10)
end
end
end
- it 'takes a max_time_ms option', if: write_command_enabled? do
+ it 'takes a max_time_ms option' do
expect {
view.count(max_time_ms: 0.1)
}.to raise_error(Mongo::Error::OperationFailure)
end
- it 'sets the max_time_ms option on the command', if: write_command_enabled? do
+ it 'sets the max_time_ms option on the command' do
expect(view.count(max_time_ms: 100)).to eq(10)
end
context 'when a collation is specified' do
@@ -828,11 +846,11 @@
expect(distinct.sort).to eq([ 'test1', 'test2', 'test3' ])
end
end
end
- context 'when a max_time_ms is specified', if: write_command_enabled? do
+ context 'when a max_time_ms is specified' do
let(:documents) do
(1..3).map{ |i| { field: "test" }}
end
@@ -958,10 +976,10 @@
authorized_collection.insert_one(name: 'bang')
authorized_collection.insert_one(name: 'BANG')
end
it 'does not apply the collation to the distinct' do
- expect(result).to eq(['bang', 'BANG'])
+ expect(result).to match_array(['bang', 'BANG'])
end
end
end
describe '#hint' do