forked from thbishop/knife-solo_data_bag
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make tests work with old or recent JSON module serialization behavior.
- Loading branch information
vagrant
committed
Nov 6, 2013
1 parent
22d23f2
commit 37047e5
Showing
3 changed files
with
43 additions
and
15 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
require 'fakefs/safe' | ||
require 'knife-solo_data_bag' | ||
|
||
|
||
def JSON_to_databag_item (json_string) | ||
#This is a fix to handle differing JSON behavior across multiple JSON module versions | ||
json_parsed = JSON.parse(json_string) | ||
#should break these into their own tests depending on JSON::VERSION value? | ||
if json_parsed.is_a? Chef::DataBagItem #old JSON deserialized it | ||
item = json_parsed | ||
elsif json_parsed.has_key?("json_class") #old serialized file format knife-solo_data_bag<=0.4.0 | ||
item = Chef::DataBagItem.json_create json_parsed #method is destructive to json_parsed | ||
else #basic hash from json file | ||
item = Chef::DataBagItem.from_hash json_parsed | ||
end | ||
end | ||
|
||
['contexts', 'helpers', 'matchers'].each do |dir| | ||
Dir[File.expand_path(File.join(File.dirname(__FILE__),dir,'*.rb'))].each {|f| require f} | ||
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
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