Skip to content

Commit 7712289

Browse files
committed
Add specs for Rex::ImageSource::Memory#initialize
1 parent a249eb1 commit 7712289

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

spec/lib/rex/image_source/memory_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,32 @@
55

66
describe Rex::ImageSource::Memory do
77

8+
let(:raw_data) { "ABCDEFGHIJKLMNOP"}
9+
10+
subject do
11+
described_class.new(raw_data)
12+
end
13+
814
describe "#initialize" do
915
subject(:memory_class) do
1016
described_class.allocate
1117
end
18+
19+
it "initializes size to data length" do
20+
memory_class.send(:initialize, raw_data)
21+
expect(memory_class.size).to eq(raw_data.length)
22+
end
23+
24+
it "initializes file_offset to 0 by default" do
25+
memory_class.send(:initialize, raw_data)
26+
expect(memory_class.file_offset).to eq(0)
27+
end
28+
29+
context "when using nil as data" do
30+
it "raises an error" do
31+
expect { memory_class.send(:initialize, nil) }.to raise_error(NoMethodError)
32+
end
33+
end
1234
end
1335

1436
describe "#read" do

0 commit comments

Comments
 (0)