|
6 | 6 | have_cpanm = program_exists?("cpanm") |
7 | 7 | if !have_cpanm |
8 | 8 | Cabin::Channel.get("rspec") \ |
9 | | - .warn("Skipping CPAN#input tests because 'cpanm' isn't in your PATH") |
| 9 | + .warn("Skipping CPAN tests because 'cpanm' isn't in your PATH") |
10 | 10 | end |
11 | 11 |
|
12 | | -is_travis = ENV["TRAVIS_OS_NAME"] && !ENV["TRAVIS_OS_NAME"].empty? |
13 | | - |
14 | 12 | describe FPM::Package::CPAN do |
15 | 13 | before do |
16 | 14 | skip("Missing cpanm program") unless have_cpanm |
|
22 | 20 | subject.cleanup |
23 | 21 | end |
24 | 22 |
|
| 23 | + it "should prepend package name prefix" do |
| 24 | + subject.attributes[:cpan_package_name_prefix] = "prefix" |
| 25 | + insist { subject.instance_eval { fix_name("Foo::Bar") } } == "prefix-Foo-Bar" |
| 26 | + end |
| 27 | + |
| 28 | + it "should wrap name in perl()" do |
| 29 | + insist { subject.instance_eval { cap_name("Foo::Bar") } } == "perl(Foo::Bar)" |
| 30 | + end |
| 31 | + |
| 32 | + it "should return successful HTTP resonse" do |
| 33 | + response = subject.instance_eval { httpfetch("https://fastapi.metacpan.org/v1/module/File::Temp") } |
| 34 | + insist { response.class } == Net::HTTPOK |
| 35 | + end |
| 36 | + |
| 37 | + it "should return successful HTTP resonse" do |
| 38 | + response = subject.instance_eval {httppost( |
| 39 | + "https://fastapi.metacpan.org/v1/release/_search", |
| 40 | + "{\"fields\":[\"download_url\"],\"filter\":{\"term\":{\"name\":\"File-Temp-0.2310\"}}}" |
| 41 | + )} |
| 42 | + insist { response.class } == Net::HTTPOK |
| 43 | + end |
| 44 | + |
| 45 | + it "should return metadata hash" do |
| 46 | + metadata = subject.instance_eval { search("File::Temp") } |
| 47 | + insist { metadata.class } == Hash |
| 48 | + insist { metadata["name"] } == "Temp.pm" |
| 49 | + insist { metadata["distribution"] } == "File-Temp" |
| 50 | + end |
| 51 | + |
| 52 | + it "should download precise version" do |
| 53 | + metadata = subject.instance_eval { search("Set::Tiny") } |
| 54 | + insist { File.basename(subject.instance_eval { download(metadata, "0.01") }) } == "Set-Tiny-0.01.tar.gz" |
| 55 | + end |
| 56 | + |
25 | 57 | it "should package Digest::MD5" do |
26 | | - pending("Disabled on travis-ci because it always fails, and there is no way to debug it?") if is_travis |
| 58 | + # Set the version explicitly because we default to installing the newest |
| 59 | + # version, and a new version could be released that breaks the test. |
| 60 | + subject.instance_variable_set(:@version, "2.58"); |
27 | 61 |
|
28 | 62 | # Disable testing because we don't really need to run the cpan tests. The |
29 | 63 | # goal is to see the parsed result (name, module description, etc) |
30 | 64 | # Additionally, it fails on my workstation when cpan_test? is enabled due |
31 | 65 | # to not finding `Test.pm`, and it seems like a flakey test if we keep this |
32 | 66 | # enabled. |
33 | 67 | subject.attributes[:cpan_test?] = false |
| 68 | + |
34 | 69 | subject.input("Digest::MD5") |
35 | 70 | insist { subject.name } == "perl-Digest-MD5" |
36 | 71 | insist { subject.description } == "Perl interface to the MD-5 algorithm" |
37 | 72 | insist { subject.vendor } == "Gisle Aas <gisle@activestate.com>" |
38 | | - # TODO(sissel): Check dependencies |
| 73 | + insist { subject.dependencies.sort } == ["perl >= 5.006", "perl(Digest::base) >= 1.00", "perl(XSLoader)"] |
39 | 74 | end |
40 | 75 |
|
41 | 76 | it "should unpack tarball containing ./ leading paths" do |
42 | | - pending("Disabled on travis-ci because it always fails, and there is no way to debug it?") if is_travis |
43 | 77 |
|
44 | 78 | Dir.mktmpdir do |tmpdir| |
45 | 79 | # Create tarball containing a file './foo/bar.txt' |
|
55 | 89 | end |
56 | 90 |
|
57 | 91 | it "should package File::Spec" do |
58 | | - pending("Disabled on travis-ci because it always fails, and there is no way to debug it?") if is_travis |
| 92 | + subject.instance_variable_set(:@version, "3.75"); |
| 93 | + subject.attributes[:cpan_test?] = false |
| 94 | + |
59 | 95 | subject.input("File::Spec") |
60 | 96 |
|
61 | 97 | # the File::Spec module comes from the PathTools CPAN distribution |
62 | 98 | insist { subject.name } == "perl-PathTools" |
63 | 99 | end |
64 | 100 |
|
65 | 101 | it "should package Class::Data::Inheritable" do |
66 | | - pending("Disabled on travis-ci because it always fails, and there is no way to debug it?") if is_travis |
67 | | - |
68 | 102 | # Class::Data::Inheritable version 0.08 has a blank author field in its |
69 | 103 | # META.yml file. |
70 | 104 | subject.instance_variable_set(:@version, "0.08"); |
| 105 | + |
| 106 | + subject.attributes[:cpan_test?] = false |
| 107 | + |
71 | 108 | subject.input("Class::Data::Inheritable") |
72 | 109 | insist { subject.vendor } == "No Vendor Or Author Provided" |
73 | 110 | end |
74 | 111 |
|
75 | 112 | context "given a distribution without a META.* file" do |
76 | 113 | it "should package IPC::Session" do |
77 | | - pending("Disabled on travis-ci because it always fails, and there is no way to debug it?") if is_travis |
78 | | - |
79 | | - # IPC::Session fails 'make test' |
| 114 | + subject.instance_variable_set(:@version, "0.05"); |
80 | 115 | subject.attributes[:cpan_test?] = false |
| 116 | + # IPC::Session fails 'make test' |
81 | 117 | subject.input("IPC::Session") |
82 | 118 | end |
83 | 119 | end |
|
0 commit comments