ruby_gpg 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +5 -0
- data/VERSION +1 -1
- data/lib/ruby_gpg.rb +3 -2
- data/ruby_gpg.gemspec +1 -1
- data/spec/ruby_gpg_spec.rb +32 -6
- metadata +1 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d1ad6b2c566e53ec312b16bce941701c2ccd6f1
|
4
|
+
data.tar.gz: 382e6a41d5ff7bf83345dad13857b84da07ec168
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11ada8a63e7d9ea993332d2febc5ebc71c153b15b22f484460dbc1666d385c0f966412cf1f7d5f873abbe5e7091a60fbbf36ddf1ec7db9d553d0398421527019
|
7
|
+
data.tar.gz: 5cbb2bc3f890f1dcab7651a3c4a36ae405ced643d5c981436abc7a21b6ef9e4faf82e371062fa8fbf4d0ec3d215436efead33c1f7381c7c543d4ef7f8b872553
|
data/CHANGELOG.markdown
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/lib/ruby_gpg.rb
CHANGED
@@ -56,12 +56,13 @@ module RubyGpg
|
|
56
56
|
|
57
57
|
def run_command(command, input = nil)
|
58
58
|
output = ""
|
59
|
-
Open3.popen3(command) do |stdin, stdout, stderr|
|
59
|
+
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
|
60
60
|
stdin.write(input) if input
|
61
61
|
stdin.close
|
62
62
|
output << stdout.read
|
63
|
+
exitcode = wait_thr.value.exitstatus
|
63
64
|
error = stderr.read
|
64
|
-
if
|
65
|
+
if exitcode != 0
|
65
66
|
raise "GPG command (#{command}) failed with: #{error}"
|
66
67
|
end
|
67
68
|
end
|
data/ruby_gpg.gemspec
CHANGED
data/spec/ruby_gpg_spec.rb
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "RubyGpg" do
|
4
|
+
class MockProcessStatus
|
5
|
+
attr_accessor :exitstatus
|
6
|
+
def initialize(exitstatus)
|
7
|
+
@exitstatus = exitstatus
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class MockProcessThread
|
12
|
+
attr_accessor :pid, :value
|
13
|
+
@pid = 1
|
14
|
+
def initialize(exitstatus)
|
15
|
+
@value = MockProcessStatus.new(exitstatus)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
4
19
|
def expect_command_to_match(part_of_command)
|
5
20
|
Open3.expects(:popen3).with do |command|
|
6
21
|
case part_of_command
|
@@ -18,12 +33,17 @@ describe "RubyGpg" do
|
|
18
33
|
@stderr.write(error_message)
|
19
34
|
@stderr.rewind
|
20
35
|
end
|
21
|
-
|
36
|
+
|
37
|
+
def stub_exitstatus(exitstatus)
|
38
|
+
@thread.value.exitstatus = exitstatus
|
39
|
+
end
|
40
|
+
|
22
41
|
before do
|
23
42
|
@stdin = StringIO.new
|
24
43
|
@stdout = StringIO.new
|
25
44
|
@stderr = StringIO.new
|
26
|
-
|
45
|
+
@thread = MockProcessThread.new(0)
|
46
|
+
Open3.stubs(:popen3).yields(@stdin, @stdout, @stderr, @thread)
|
27
47
|
end
|
28
48
|
|
29
49
|
it "allows the use of a custom path to the gpg executable" do
|
@@ -76,11 +96,13 @@ describe "RubyGpg" do
|
|
76
96
|
end
|
77
97
|
|
78
98
|
it "raises any errors from gpg" do
|
79
|
-
stub_error("error message")
|
99
|
+
stub_error("error message")
|
100
|
+
stub_exitstatus(1)
|
80
101
|
lambda { run_encrypt }.should raise_error(/GPG command \(.*gpg.*--encrypt.*filename\) failed with: error message/)
|
81
102
|
end
|
82
103
|
|
83
|
-
it "does not raise if
|
104
|
+
it "does not raise if gpg exit status is 0" do
|
105
|
+
stub_error("error message")
|
84
106
|
lambda { run_encrypt }.should_not raise_error
|
85
107
|
end
|
86
108
|
end
|
@@ -174,10 +196,12 @@ describe "RubyGpg" do
|
|
174
196
|
|
175
197
|
it "raises any errors from gpg" do
|
176
198
|
stub_error("error message")
|
199
|
+
stub_exitstatus(1)
|
177
200
|
lambda { run_decrypt }.should raise_error(/GPG command \(.*gpg.*--decrypt.*filename\.gpg\) failed with: error message/)
|
178
201
|
end
|
179
202
|
|
180
|
-
it "does not raise if
|
203
|
+
it "does not raise if gpg exits with 0" do
|
204
|
+
stub_error("error message")
|
181
205
|
lambda { run_decrypt }.should_not raise_error
|
182
206
|
end
|
183
207
|
end
|
@@ -234,10 +258,12 @@ describe "RubyGpg" do
|
|
234
258
|
|
235
259
|
it "raises any errors from gpg" do
|
236
260
|
stub_error("error message")
|
261
|
+
stub_exitstatus(1)
|
237
262
|
lambda { run_decrypt_string }.should raise_error(/GPG command \(.*gpg.*--decrypt.*\) failed with: error message/)
|
238
263
|
end
|
239
264
|
|
240
|
-
it "does not raise if
|
265
|
+
it "does not raise if gpg exitstatus is 0" do
|
266
|
+
stub_error("error message")
|
241
267
|
lambda { run_decrypt_string }.should_not raise_error
|
242
268
|
end
|
243
269
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_gpg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Blake
|
@@ -136,4 +136,3 @@ summary: Ruby wrapper for the gpg binary
|
|
136
136
|
test_files:
|
137
137
|
- spec/ruby_gpg_spec.rb
|
138
138
|
- spec/spec_helper.rb
|
139
|
-
has_rdoc:
|