-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handled syntax error also refactored code and added test cases for th…
…e changes Signed-off-by: sanga17 <sausekar@msystechnologies.com>
- Loading branch information
Showing
2 changed files
with
29 additions
and
6 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
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,24 @@ | ||
require "spec_helper" | ||
require "chef/knife/mixin/helper" | ||
|
||
RSpec.describe ChefVault::Mixin::Helper do | ||
include ChefVault::Mixin::Helper | ||
|
||
let(:json_data) { '{"username": "root", "password": "abcabc"}' } | ||
let(:json_data_control_char) { '{"username": "root", "password": "abc\abc"}' } | ||
let(:buggy_json_data) { '{"username": "root", "password": "abc\abc"' } | ||
|
||
describe "#validate_json" do | ||
it "Raises InvalidValue Exception when invalid data provided" do | ||
expect { validate_json(buggy_json_data) }.to raise_error(ChefVault::Exceptions::InvalidValue) | ||
end | ||
|
||
it "Raises InvalidValue Exception when value consist of control characters" do | ||
expect { validate_json(json_data_control_char) }.to raise_error(ChefVault::Exceptions::InvalidValue) | ||
end | ||
|
||
it "Not to raise error if valid data provided" do | ||
expect { validate_json(json_data) }.to_not raise_error | ||
end | ||
end | ||
end |