Merge pull request #2034 from reitermarkus/spec-gpg

Convert Gpg test to spec.
This commit is contained in:
Markus Reiter 2017-02-20 13:47:30 +01:00 committed by GitHub
commit dfad3f33ca
2 changed files with 21 additions and 18 deletions

View File

@ -0,0 +1,21 @@
require "gpg"
describe Gpg do
subject { described_class }
describe "::create_test_key" do
it "creates a test key in the home directory" do
skip "GPG Unavailable" unless subject.available?
Dir.mktmpdir do |dir|
ENV["HOME"] = dir
dir = Pathname.new(dir)
shutup do
subject.create_test_key(dir)
end
expect(dir/".gnupg/secring.gpg").to exist
end
end
end
end

View File

@ -1,18 +0,0 @@
require "testing_env"
require "gpg"
class GpgTest < Homebrew::TestCase
def setup
super
skip "GPG Unavailable" unless Gpg.available?
@dir = Pathname.new(mktmpdir)
end
def test_create_test_key
Dir.chdir(@dir) do
ENV["HOME"] = @dir
shutup { Gpg.create_test_key(@dir) }
assert_predicate @dir/".gnupg/secring.gpg", :exist?
end
end
end