From e88b1c54454b7a811cef75607a1becf600902d5b Mon Sep 17 00:00:00 2001 From: Sourav Goswami Date: Mon, 6 Sep 2021 14:01:26 +0530 Subject: [PATCH] Update test for old LibmagicRb version 5.11 --- spec/libmagic_rb_spec.rb | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/spec/libmagic_rb_spec.rb b/spec/libmagic_rb_spec.rb index 80c4663..72872d7 100644 --- a/spec/libmagic_rb_spec.rb +++ b/spec/libmagic_rb_spec.rb @@ -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" @@ -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