Skip to content

Commit

Permalink
Update test for old LibmagicRb version 5.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Souravgoswami committed Sep 6, 2021
1 parent 06e1349 commit e88b1c5
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions spec/libmagic_rb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ def self.get() @c.rotate![0] end
end

# Flags / Modes
it "#{Bullet.get} can change modes with setflags" do
cookie = LibmagicRb.new(file: ?.)

cookie.file = __FILE__
cookie.setflags(LibmagicRb::MAGIC_RAW)

check = cookie.check
expect(check == "Ruby module source, ASCII text" || check == "Ruby script, ASCII text").to be true

cookie.file = Dir.pwd
cookie.setflags(LibmagicRb::MAGIC_MIME_ENCODING)
expect(cookie.check).to be == "binary"

cookie.close
end

it "#{Bullet.get} can change modes on the fly" do
cookie = LibmagicRb.new(file: ?.)
expect(cookie.check).to be == "inode/directory; charset=binary"
Expand All @@ -63,21 +79,13 @@ def self.get() @c.rotate![0] end

cookie.file = __FILE__
cookie.mode = LibmagicRb::MAGIC_RAW
expect(cookie.check).to be == "Ruby script, ASCII text"

cookie.file = Dir.pwd
cookie.mode = LibmagicRb::MAGIC_MIME_ENCODING
expect(cookie.check).to be == "binary"

cookie.file = __FILE__
cookie.setflags(LibmagicRb::MAGIC_RAW)
expect(cookie.check).to be == "Ruby script, ASCII text"
check = cookie.check
expect(check == "Ruby module source, ASCII text" || check == "Ruby script, ASCII text").to be true

cookie.file = Dir.pwd
cookie.setflags(LibmagicRb::MAGIC_MIME_ENCODING)
cookie.mode = LibmagicRb::MAGIC_MIME_ENCODING
expect(cookie.check).to be == "binary"

cookie.close
end

# Magic Buffer
Expand Down

0 comments on commit e88b1c5

Please sign in to comment.