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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddc082532dfd54e87fcf5397f812a356cb6e2c88
4
- data.tar.gz: da78a488b46f410a1a0065e928d8c947899c6ff0
3
+ metadata.gz: 6d1ad6b2c566e53ec312b16bce941701c2ccd6f1
4
+ data.tar.gz: 382e6a41d5ff7bf83345dad13857b84da07ec168
5
5
  SHA512:
6
- metadata.gz: 34c146085c41bf2bcf1dd01da8ab47b0c2408879d95d0d47a03b2e7897252ebe3cb35311c1bc1d0ac513481c49e90e95b45b6a074b86d6713d764e3a914f68f1
7
- data.tar.gz: 82e35ad90b5912635453b6608362558730769b2d5e3e417207d556c9290dc3c32ab31d0ce47ff9e78cc082fa5ca3154b2e2610220e96aa50c51e02433bdff795
6
+ metadata.gz: 11ada8a63e7d9ea993332d2febc5ebc71c153b15b22f484460dbc1666d385c0f966412cf1f7d5f873abbe5e7091a60fbbf36ddf1ec7db9d553d0398421527019
7
+ data.tar.gz: 5cbb2bc3f890f1dcab7651a3c4a36ae405ced643d5c981436abc7a21b6ef9e4faf82e371062fa8fbf4d0ec3d215436efead33c1f7381c7c543d4ef7f8b872553
@@ -1,3 +1,8 @@
1
+ # v0.3.2 (2015-04-21)
2
+
3
+ * Check exit status instead of contents of stderr (e97bea52)
4
+ * Stop using jeweler to manage gemspec and releases (978a6124)
5
+
1
6
  # v0.3.1 (2014-02-27)
2
7
 
3
8
  * Make it work in jruby (2916bbba92d1b9a4fd2847883ed27c77617295a5)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -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 error && !error.empty?
65
+ if exitcode != 0
65
66
  raise "GPG command (#{command}) failed with: #{error}"
66
67
  end
67
68
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ruby_gpg}
5
- s.version = "0.3.1"
5
+ s.version = "0.3.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Justin Blake"]
@@ -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
- Open3.stubs(:popen3).yields(@stdin, @stdout, @stderr)
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 there is no output from gpg" do
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 there is no output from gpg" do
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 there is no output from gpg" do
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.1
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: