nrser 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 385b44525f971891d33ea5f79bed8bb753d56cdd
4
- data.tar.gz: 175428eb1a8544148606e3f75813b23bb0e3b80b
3
+ metadata.gz: 700ca721f5a9c6e1b301a42b06cca6ee01aab576
4
+ data.tar.gz: ce5fb2e55d3ad6d279858e3ccbdc252d29097bdf
5
5
  SHA512:
6
- metadata.gz: 634f88d8cb06dcb733667b1234e5e4b8a296f0f426ecd22de23d2eb19d83b713f0440ce63011fdcaf4b67a92ef333587a4f74750eca6c690b4ea578464948883
7
- data.tar.gz: b696d80c061d3d6f570e0192636763b80f468c873f698181b3db691cd4664451dc2067cb230fca573d5d17b5d72627f6b7c4e127d02a379152ca829b39b6beae
6
+ metadata.gz: 6da44b20707d9df1ead93f5b58c2c27ddbdbbeda37a60235a81e752ed8d40b1c3130705596ab0e141a01b534db383ed4f3f597f751b7f3a7b2c00048137fcad6
7
+ data.tar.gz: 5404fe037bdc814a4ad7e171b8b5070c587173b6906be09e8ef5630d09d07820bffef42ff31ca2ce16c74336e6f5e3fa64e72ab3032898446f95b7e6ace84549
data/lib/nrser/exec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'shellwords'
2
+
1
3
  require 'nrser'
2
4
 
3
5
  using NRSER
@@ -19,9 +21,17 @@ module NRSER::Exec
19
21
  BLOCK
20
22
  end
21
23
 
24
+ def check_error
25
+ raise_error unless success?
26
+ end
27
+
22
28
  def success?
23
29
  @exitstatus == 0
24
30
  end
31
+
32
+ def failure?
33
+ ! success?
34
+ end
25
35
  end
26
36
 
27
37
  # substitute stuff into a shell command after escaping with
data/lib/nrser/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module NRSER
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -0,0 +1,77 @@
1
+ require 'shellwords'
2
+
3
+ require 'spec_helper'
4
+
5
+ require 'nrser/exec'
6
+
7
+ describe "NRSER::Exec.result" do
8
+ context "successful command" do
9
+ msg = "hey!"
10
+
11
+ let(:result) {
12
+ NRSER::Exec.result "echo %{msg}", msg: msg
13
+ }
14
+
15
+ it "should have exitstatus 0" do
16
+ expect( result.exitstatus ).to eq 0
17
+ end
18
+
19
+ it "should return true for #success?" do
20
+ expect( result.success? ).to be true
21
+ end
22
+
23
+ it "should return false for #failure?" do
24
+ expect( result.failure? ).to be false
25
+ end
26
+
27
+ it "should not raise an error on #check_error" do
28
+ expect{ result.check_error }.not_to raise_error
29
+ end
30
+
31
+ it "should raise Errno::NOERROR on #raise_error" do
32
+ expect{ result.raise_error }.to raise_error Errno::NOERROR
33
+ end
34
+
35
+ it "should have output 'hey!\\n'" do
36
+ expect( result.output ).to eq "hey!\n"
37
+ end
38
+
39
+ it %{should have cmd "echo #{ Shellwords.escape(msg) }"} do
40
+ expect( result.cmd ).to eq "echo #{ Shellwords.escape(msg) }"
41
+ end
42
+ end
43
+
44
+ context "failed command" do
45
+ let(:result) {
46
+ NRSER::Exec.result "false"
47
+ }
48
+
49
+ it "should not have exitstatus 0" do
50
+ expect( result.exitstatus ).not_to eq 0
51
+ end
52
+
53
+ it "should return false for #success?" do
54
+ expect( result.success? ).to be false
55
+ end
56
+
57
+ it "should return true for #failure?" do
58
+ expect( result.failure? ).to be true
59
+ end
60
+
61
+ it "should raise an error on #check_error" do
62
+ expect{ result.check_error }.to raise_error Errno::EPERM
63
+ end
64
+
65
+ it "should raise Errno::EPERM on #raise_error" do
66
+ expect{ result.raise_error }.to raise_error Errno::EPERM
67
+ end
68
+
69
+ it "should have output ''" do
70
+ expect( result.output ).to eq ""
71
+ end
72
+
73
+ it "should have cmd 'false'" do
74
+ expect( result.cmd ).to eq "false"
75
+ end
76
+ end
77
+ end # describe result
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nrser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-09 00:00:00.000000000 Z
11
+ date: 2015-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,7 @@ files:
72
72
  - nrser.gemspec
73
73
  - spec/nrser/common_prefix_spec.rb
74
74
  - spec/nrser/dedent_spec.rb
75
+ - spec/nrser/exec/result_spec.rb
75
76
  - spec/nrser/exec/run_spec.rb
76
77
  - spec/nrser/exec/sub_spec.rb
77
78
  - spec/nrser/format_exception_spec.rb
@@ -108,6 +109,7 @@ summary: basic ruby utils i use in a lot of stuff.
108
109
  test_files:
109
110
  - spec/nrser/common_prefix_spec.rb
110
111
  - spec/nrser/dedent_spec.rb
112
+ - spec/nrser/exec/result_spec.rb
111
113
  - spec/nrser/exec/run_spec.rb
112
114
  - spec/nrser/exec/sub_spec.rb
113
115
  - spec/nrser/format_exception_spec.rb