File: limit_resources_spec.rb

package info (click to toggle)
ruby-rmagick 6.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,232 kB
  • sloc: cpp: 19,563; ruby: 17,147; sh: 88; javascript: 36; makefile: 13
file content (46 lines) | stat: -rw-r--r-- 2,092 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
RSpec.describe Magick, '.limit_resources' do
  xit 'works' do
    cur = new = nil

    expect { cur = described_class.limit_resource(:memory, 500) }.not_to raise_error
    expect(cur).to be_kind_of(Integer)
    expect(cur > 1024**2).to be(true)
    expect { new = described_class.limit_resource('memory') }.not_to raise_error
    expect(new).to eq(500)
    described_class.limit_resource(:memory, cur)

    expect { cur = described_class.limit_resource(:map, 3500) }.not_to raise_error
    expect(cur).to be_kind_of(Integer)
    expect(cur > 1024**2).to be(true)
    expect { new = described_class.limit_resource('map') }.not_to raise_error
    expect(new).to eq(3500)
    described_class.limit_resource(:map, cur)

    expect { cur = described_class.limit_resource(:disk, 3 * 1024 * 1024 * 1024) }.not_to raise_error
    expect(cur).to be_kind_of(Integer)
    expect(cur > 1024**2).to be(true)
    expect { new = described_class.limit_resource('disk') }.not_to raise_error
    expect(new).to eq(3_221_225_472)
    described_class.limit_resource(:disk, cur)

    expect { cur = described_class.limit_resource(:file, 500) }.not_to raise_error
    expect(cur).to be_kind_of(Integer)
    expect(cur > 100).to be(true)
    expect { new = described_class.limit_resource('file') }.not_to raise_error
    expect(new).to eq(500)
    described_class.limit_resource(:file, cur)

    expect { described_class.limit_resource(:time, 123) }.not_to raise_error
    expect { cur = described_class.limit_resource(:time, 300) }.not_to raise_error
    expect(cur).to be_kind_of(Integer)
    expect(cur).to eq(123)
    expect { new = described_class.limit_resource('time') }.not_to raise_error
    expect(new).to eq(300)
    described_class.limit_resource(:time, cur)

    expect { described_class.limit_resource(:xxx) }.to raise_error(ArgumentError)
    expect { described_class.limit_resource('xxx') }.to raise_error(ArgumentError)
    expect { described_class.limit_resource('map', 3500, 2) }.to raise_error(ArgumentError)
    expect { described_class.limit_resource }.to raise_error(ArgumentError)
  end
end