File: stream_spec.rb

package info (click to toggle)
ruby-mongo 2.5.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 4,320 kB
  • sloc: ruby: 45,579; makefile: 5; sh: 2
file content (48 lines) | stat: -rw-r--r-- 988 bytes parent folder | download | duplicates (4)
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
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