Convert Gpg test to spec.

This commit is contained in:
Markus Reiter 2017-02-16 18:14:05 +01:00
parent 5a2a063802
commit 99da779434
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