File: stream_spec.rb

package info (click to toggle)
ruby-mongo 2.21.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,764 kB
  • sloc: ruby: 108,806; makefile: 5; sh: 2
file content (51 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true
# rubocop:todo all

require 'spec_helper'

describe Mongo::Grid::FSBucket::Stream do

  let(:fs) do
    authorized_client.database.fs
  end

  describe '.get' do

    let(:stream) do
      described_class.get(fs, mode)
    end

    context 'when mode is read' do

      let(:mode) do
        Mongo::Grid::FSBucket::Stream::READ_MODE
      end

      it 'returns a Stream::Read object' do
        expect(stream).to be_a(Mongo::Grid::FSBucket::Stream::Read)
      end
    end

    context 'when mode is write' do

      let(:mode) do
        Mongo::Grid::FSBucket::Stream::WRITE_MODE
      end

      it 'returns a Stream::Write object' do
        expect(stream).to be_a(Mongo::Grid::FSBucket::Stream::Write)
      end

      context 'when options are provided' do

        let(:stream) do
          described_class.get(fs, mode, chunk_size: 100)
        end

        it 'sets the options on the stream object' do
          expect(stream.options[:chunk_size]).to eq(100)
        end
      end
    end
  end
end