1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (test-gem)
21 #:use-module (guix import gem)
22 #:use-module (guix base32)
23 #:use-module (guix hash)
24 #:use-module (guix tests)
25 #:use-module ((guix build utils) #:select (delete-file-recursively))
26 #:use-module (srfi srfi-64)
27 #:use-module (ice-9 match))
32 \"version\": \"1.0.0\",
33 \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\",
34 \"info\": \"A cool gem\",
35 \"homepage_uri\": \"https://example.com\",
38 { \"name\": \"bundler\" },
42 \"licenses\": [\"MIT\", \"Apache 2.0\"]
47 (test-assert "gem->guix-package"
48 ;; Replace network resources with sample data.
49 (mock ((guix http-client) http-fetch
52 ("https://rubygems.org/api/v1/gems/foo.json"
53 (values (open-input-string test-json)
54 (string-length test-json)))
55 (_ (error "Unexpected URL: " url)))))
56 (match (gem->guix-package "foo")
62 ('uri ('rubygems-uri "foo" 'version))
65 "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
66 ('build-system 'ruby-build-system)
69 (("bundler" ('unquote 'bundler))
70 ("ruby-bar" ('unquote 'ruby-bar)))))
71 ('synopsis "A cool gem")
72 ('description "This package provides a cool gem")
73 ('home-page "https://example.com")
74 ('license ('list 'license:expat 'license:asl2.0)))