Subject: [PATCH 147/223] gnu: ruby-marcel: Enable tests.

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 20 Mar 2023 13:22:33 -0400

* gnu/packages/rails.scm (ruby-marcel) [source]: Fetch from git.
[arguments]: Drop #:tests?. Add #:phases.
[native-inputs]: New field.
---

 gnu/packages/rails.scm | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/gnu/packages/rails.scm b/gnu/packages/rails.scm
index 9638aee3ae..540c69ec2f 100644
--- a/gnu/packages/rails.scm
+++ b/gnu/packages/rails.scm
@@ -730,19 +730,30 @@ (define-public ruby-marcel
   (package
     (name "ruby-marcel")
     (version "1.0.2")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (rubygems-uri "marcel" version))
-       (sha256
-        (base32
-         "0kky3yiwagsk8gfbzn3mvl2fxlh3b39v6nawzm4wpjs6xxvvc4x0"))))
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/rails/marcel")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1i1x24afmn09n48fj4yz2pdm6vlfnq14gism0cgxsyqmlrvsxajn"))))
     (build-system ruby-build-system)
     (arguments
-     '(;; No included tests
-       #:tests? #f))
-    (propagated-inputs
-     (list ruby-mimemagic))
+     (list #:test-target "default"
+           #:phases #~(modify-phases %standard-phases
+                        (add-before 'check 'disable-problematic-tests
+                          (lambda _
+                            (substitute* "test/mime_type_test.rb"
+                              ;; One test fails because of the newer rack
+                              ;; version used (see:
+                              ;; https://github.com/rails/marcel/issues/91).
+                              (("test \"gets content type.*" all)
+                               (string-append
+                                all "    skip('fails on guix')\n"))))))))
+    (native-inputs (list ruby-byebug ruby-nokogiri ruby-rack))
+    (propagated-inputs (list ruby-mimemagic))
     (synopsis "MIME type detection using magic numbers, filenames and extensions")
     (description
      "@code{marcel} provides @acronym{MIME, Multipurpose Internet Mail
-- 
2.39.1