-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #564 from takaishi/add_resource_type_for_json_file
add resource type json file
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'json' | ||
|
||
module Serverspec::Type | ||
class JsonFile < File | ||
def content | ||
JSON.parse(super) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
set :os, {:family => 'base'} | ||
|
||
describe json_file('example.json') do | ||
let(:stdout) {<<EOF | ||
{ | ||
"json": { | ||
"title": "this is a json", | ||
"array" : [ | ||
{ | ||
"title": "array 1" | ||
}, | ||
{ | ||
"title": "array 2" | ||
} | ||
] | ||
} | ||
} | ||
EOF | ||
} | ||
|
||
its(:content) { should include('json') } | ||
its(:content) { should include('json' => include('title' => 'this is a json')) } | ||
its(:content) { should include('json' => include('array' => include('title' => 'array 2'))) } | ||
end | ||
|