diff options
author | Luke Kanies <luke@puppetlabs.com> | 2011-04-12 23:54:08 -0700 |
---|---|---|
committer | Luke Kanies <luke@puppetlabs.com> | 2011-04-14 17:07:39 -0700 |
commit | e424740d78b8b72dc6bd7ebbbe27b237347d67f5 (patch) | |
tree | 9f2afddc64f32990f298689e327ac05fcb2b4719 /spec/unit/indirector | |
parent | f37b2e106ed171042c94a1a0b8fd31a254a69588 (diff) | |
download | puppet-e424740d78b8b72dc6bd7ebbbe27b237347d67f5.tar.gz puppet-e424740d78b8b72dc6bd7ebbbe27b237347d67f5.tar.xz puppet-e424740d78b8b72dc6bd7ebbbe27b237347d67f5.zip |
Adding json-specific matchers
These make the JSON tests much easier to read and
write. They're the first custom matchers that I can
find, so they're breaking a bit of new ground,
but the JSON tests were pretty hard to read
and there was a lot of duplication, so it seemed
worth it.
Note that for some reason they're not working on
Facts - it seems to get immediately turned into
a full instance by the JSON parsing subsystem,
and I've no idea why.
Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'spec/unit/indirector')
-rwxr-xr-x | spec/unit/indirector/request_spec.rb | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/spec/unit/indirector/request_spec.rb b/spec/unit/indirector/request_spec.rb index 4dabb3147..ba7dc815e 100755 --- a/spec/unit/indirector/request_spec.rb +++ b/spec/unit/indirector/request_spec.rb @@ -1,5 +1,6 @@ #!/usr/bin/env rspec require 'spec_helper' +require 'matchers/json' require 'puppet/indirector/request' describe Puppet::Indirector::Request do @@ -307,28 +308,24 @@ describe Puppet::Indirector::Request do end it "should produce a hash with the document_type set to 'request'" do - PSON.parse(@request.to_pson)["document_type"].should == "Puppet::Indirector::Request" - end - - it "should add its data under the 'data' attribute in the hash" do - PSON.parse(@request.to_pson)["data"].should be_instance_of(Hash) + @request.should set_json_document_type_to("Puppet::Indirector::Request") end it "should set the 'key'" do - PSON.parse(@request.to_pson)["data"]['key'].should == "foo" + @request.should set_json_attribute("key").to("foo") end it "should include an attribute for its indirection name" do - PSON.parse(@request.to_pson)["data"]['type'].should == "facts" + @request.should set_json_attribute("type").to("facts") end it "should include a 'method' attribute set to its method" do - PSON.parse(@request.to_pson)["data"]['method'].should == "find" + @request.should set_json_attribute("method").to("find") end it "should add all attributes under the 'attributes' attribute" do @request.ip = "127.0.0.1" - PSON.parse(@request.to_pson)["data"]['attributes']['ip'].should == "127.0.0.1" + @request.should set_json_attribute("attributes", "ip").to("127.0.0.1") end it "should add all options under the 'attributes' attribute" do |