serverspec 2.33.0 → 2.34.0

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: e8cb6202bb17b2d00ab02b03db491a3f202115c6
4
- data.tar.gz: 384cf92bdcfb12da69e2ace11aa9d73556d59715
3
+ metadata.gz: bf7439e1ec9e7900ebd5a395bc1e63e1cb0359b1
4
+ data.tar.gz: a8c845da7060aabd77ba705c58dcb462e29b3974
5
5
  SHA512:
6
- metadata.gz: 612c03a69be35c981006c1df4ada37ba9e7328bbc5c78440328bd816d13989229902265cce594ce9d9c76443364ffca68c76cf41bad291853e6e8749117c3429
7
- data.tar.gz: 256da65cc862344419a75e1051758a3462d9609a0548c5a2f5c96d7fc5b96d12e2ddd0dbe800880a106e0ab95d3890840a3d4f6fcf6409fb41903a160026e7fa
6
+ metadata.gz: c8fb0b89e757f2b9783d988cc03294e0108f5bdfbb1c5d80fdaa137d43807eebda7fcfae5ec513787510fec09e1f2b9576538510e680e336817784f49691d4a9
7
+ data.tar.gz: 8b1b314700022e1c914a55824777167fe014747674c50a49cbd3907067ef4bd6b96bcebbdd865298324c5c17f77de062cba1da0f841e0f55e166ee1fb13cbbf6
@@ -1,4 +1,5 @@
1
1
  require 'date'
2
+ require 'multi_json'
2
3
 
3
4
  module Serverspec::Type
4
5
  class File < Base
@@ -113,6 +114,14 @@ module Serverspec::Type
113
114
  @content
114
115
  end
115
116
 
117
+ def content_as_json
118
+ if @content_as_json.nil?
119
+ @content = @runner.get_file_content(@name).stdout if @content.nil?
120
+ @content_as_json = MultiJson.load(@content)
121
+ end
122
+ @content_as_json
123
+ end
124
+
116
125
  def group
117
126
  @runner.get_file_owner_group(@name).stdout.strip
118
127
  end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "2.33.0"
2
+ VERSION = "2.34.0"
3
3
  end
@@ -342,6 +342,29 @@ EOF
342
342
  its(:content) { should match /root:x:0:0/ }
343
343
  end
344
344
 
345
+ describe file('example.json') do
346
+ let(:stdout) {<<EOF
347
+ {
348
+ "json": {
349
+ "title": "this is a json",
350
+ "array" : [
351
+ {
352
+ "title": "array 1"
353
+ },
354
+ {
355
+ "title": "array 2"
356
+ }
357
+ ]
358
+ }
359
+ }
360
+ EOF
361
+ }
362
+
363
+ its(:content_as_json) { should include('json') }
364
+ its(:content_as_json) { should include('json' => include('title' => 'this is a json')) }
365
+ its(:content_as_json) { should include('json' => include('array' => include('title' => 'array 2'))) }
366
+ end
367
+
345
368
  describe file('/etc/pam.d/system-auth') do
346
369
  let(:stdout) { "/etc/pam.dsystem-auth-ac\r\n" }
347
370
  its(:link_target) { should eq '/etc/pam.dsystem-auth-ac' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.33.0
4
+ version: 2.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec