snap_spec.rb (fpm-1.13.1) | : | snap_spec.rb (fpm-1.14.0) | ||
---|---|---|---|---|
require "spec_setup" | require "spec_setup" | |||
require "fpm" # local | require "fpm" # local | |||
require "English" # for $CHILD_STATUS | require "English" # for $CHILD_STATUS | |||
is_old_ruby = (RUBY_VERSION =~ /^((1\.)|(2\.0))/) | IS_OLD_RUBY = (RUBY_VERSION =~ /^((1\.)|(2\.0))/) | |||
describe FPM::Package::Snap do | describe FPM::Package::Snap do | |||
let(:target) { Stud::Temporary.pathname + ".snap" } | let(:target) { Stud::Temporary.pathname + ".snap" } | |||
before do | ||||
skip("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Psych::sa | ||||
fe_load") if IS_OLD_RUBY | ||||
skip("Missing program 'mksquashfs'") unless program_exists?("mksquashfs") | ||||
end | ||||
after do | after do | |||
subject.cleanup | subject.cleanup | |||
File.unlink(target) if File.exist?(target) | File.unlink(target) if File.exist?(target) | |||
end | end | |||
describe "#to_s" do | describe "#to_s" do | |||
before do | before do | |||
subject.name = "name" | subject.name = "name" | |||
subject.version = "123" | subject.version = "123" | |||
subject.architecture = "all" | subject.architecture = "all" | |||
subject.iteration = "100" | subject.iteration = "100" | |||
subject.epoch = "5" | subject.epoch = "5" | |||
end | end | |||
it "should have a default output usable as a filename" do | it "should have a default output usable as a filename" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Psyc h::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Psyc h::safe_load") if IS_OLD_RUBY | |||
# This is the default filename commonly produced by snapcraft | # This is the default filename commonly produced by snapcraft | |||
insist { subject.to_s } == "name_123-100_all.snap" | insist { subject.to_s } == "name_123-100_all.snap" | |||
end | end | |||
context "when iteration is nil" do | context "when iteration is nil" do | |||
before do | before do | |||
subject.iteration = nil | subject.iteration = nil | |||
end | end | |||
it "should not include iteration if it is nil" do | it "should not include iteration if it is nil" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
# This is the default filename commonly produced by snapcraft | # This is the default filename commonly produced by snapcraft | |||
expect(subject.to_s).to(be == "name_123_all.snap") | expect(subject.to_s).to(be == "name_123_all.snap") | |||
end | end | |||
end | end | |||
end | end | |||
describe "#output" do | describe "#output" do | |||
let(:original) { FPM::Package::Snap.new } | let(:original) { FPM::Package::Snap.new } | |||
let(:input) { FPM::Package::Snap.new } | let(:input) { FPM::Package::Snap.new } | |||
skipping to change at line 92 | skipping to change at line 96 | |||
input.cleanup | input.cleanup | |||
end | end | |||
context "package attributes" do | context "package attributes" do | |||
before do | before do | |||
original.output(target) | original.output(target) | |||
input.input(target) | input.input(target) | |||
end | end | |||
it "should have the correct name" do | it "should have the correct name" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.name } == original.name | insist { input.name } == original.name | |||
end | end | |||
it "should have the correct version" do | it "should have the correct version" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.version } == original.version | insist { input.version } == original.version | |||
end | end | |||
it "should have the correct description" do | it "should have the correct description" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.description } == original.description | insist { input.description } == original.description | |||
end | end | |||
it "should have the correct architecture" do | it "should have the correct architecture" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.architecture } == original.architecture | insist { input.architecture } == original.architecture | |||
end | end | |||
it "should have the correct apps" do | it "should have the correct apps" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.attributes[:snap_apps] } == original.attributes[:snap_app s] | insist { input.attributes[:snap_apps] } == original.attributes[:snap_app s] | |||
end | end | |||
it "should have the correct hooks" do | it "should have the correct hooks" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.attributes[:snap_hooks] } == original.attributes[:snap_ho oks] | insist { input.attributes[:snap_hooks] } == original.attributes[:snap_ho oks] | |||
end | end | |||
end | end | |||
context "with custom snap.yaml" do | context "with custom snap.yaml" do | |||
let(:snap_yaml) { Stud::Temporary.pathname + ".yaml" } | let(:snap_yaml) { Stud::Temporary.pathname + ".yaml" } | |||
before do | before do | |||
File.write(snap_yaml, { | File.write(snap_yaml, { | |||
"name" => "custom-name", | "name" => "custom-name", | |||
skipping to change at line 145 | skipping to change at line 149 | |||
original.output(target) | original.output(target) | |||
input.input(target) | input.input(target) | |||
end | end | |||
after do | after do | |||
subject.cleanup | subject.cleanup | |||
File.unlink(snap_yaml) if File.exist?(snap_yaml) | File.unlink(snap_yaml) if File.exist?(snap_yaml) | |||
end | end | |||
it "should have the custom name" do | it "should have the custom name" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.name } == "custom-name" | insist { input.name } == "custom-name" | |||
end | end | |||
it "should have the custom version" do | it "should have the custom version" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.version } == "custom-version" | insist { input.version } == "custom-version" | |||
end | end | |||
it "should have the custom description" do | it "should have the custom description" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.description } == "custom-summary\ncustom-description" | insist { input.description } == "custom-summary\ncustom-description" | |||
end | end | |||
it "should have the custom architecture" do | it "should have the custom architecture" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.architecture } == "custom-architecture" | insist { input.architecture } == "custom-architecture" | |||
end | end | |||
it "should have the custom apps" do | it "should have the custom apps" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.attributes[:snap_apps] } == [] | insist { input.attributes[:snap_apps] } == [] | |||
end | end | |||
it "should have the custom hooks" do | it "should have the custom hooks" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Ps ych::safe_load") if IS_OLD_RUBY | |||
insist { input.attributes[:snap_hooks] } == [] | insist { input.attributes[:snap_hooks] } == [] | |||
end | end | |||
end | end | |||
it "should support specifying confinement" do | it "should support specifying confinement" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Psyc h::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Psyc h::safe_load") if IS_OLD_RUBY | |||
original.attributes[:snap_confinement] = "test-confinement" | original.attributes[:snap_confinement] = "test-confinement" | |||
original.output(target) | original.output(target) | |||
input.input(target) | input.input(target) | |||
insist { input.attributes[:snap_confinement] } == "test-confinement" | insist { input.attributes[:snap_confinement] } == "test-confinement" | |||
end | end | |||
it "should support specifying grade" do | it "should support specifying grade" do | |||
pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Psyc h::safe_load") if is_old_ruby | pending("Ruby 1.x and 2.0.x are unsupported for Snap because it lacks Psyc h::safe_load") if IS_OLD_RUBY | |||
original.attributes[:snap_grade] = "test-grade" | original.attributes[:snap_grade] = "test-grade" | |||
original.output(target) | original.output(target) | |||
input.input(target) | input.input(target) | |||
insist { input.attributes[:snap_grade] } == "test-grade" | insist { input.attributes[:snap_grade] } == "test-grade" | |||
end | end | |||
end | end | |||
end | end | |||
End of changes. 18 change blocks. | ||||
17 lines changed or deleted | 22 lines changed or added |