diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-28 10:57:51 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-28 10:57:51 -0700 |
| commit | db14f1240be7e20ba04c0fdf448044b36ce24ceb (patch) | |
| tree | 124ebc6761561c0d94f9a314e1a169aae90a8355 /spec | |
| parent | ebf49f98357f93b33e09c0ecbdee1c5c2db87569 (diff) | |
| parent | 632a0a0042ebf2e7ef209ce30005833ccee6e77b (diff) | |
| download | puppet-db14f1240be7e20ba04c0fdf448044b36ce24ceb.tar.gz puppet-db14f1240be7e20ba04c0fdf448044b36ce24ceb.tar.xz puppet-db14f1240be7e20ba04c0fdf448044b36ce24ceb.zip | |
Merge branch 'feature/2.7.x/7160-support-json-externally' into 2.7.x
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/application/face_base_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/unit/application/face_base_spec.rb b/spec/unit/application/face_base_spec.rb index 7b3a69f61..0c75236f8 100755 --- a/spec/unit/application/face_base_spec.rb +++ b/spec/unit/application/face_base_spec.rb @@ -296,5 +296,26 @@ EOT app.action.render_as = :for_humans app.render("bi-polar?").should == "bi-winning!" end + + it "should render JSON when asked for json" do + app.action.render_as = :json + json = app.render({ :one => 1, :two => 2 }) + json.should =~ /"one":\s*1\b/ + json.should =~ /"two":\s*2\b/ + PSON.parse(json).should == { "one" => 1, "two" => 2 } + end + + it "should fail early if asked to render an invalid format" do + app.command_line.stubs(:args).returns %w{--render-as interpretive-dance help help} + # We shouldn't get here, thanks to the exception, and our expectation on + # it, but this helps us fail if that slips up and all. --daniel 2011-04-27 + Puppet::Face[:help, :current].expects(:help).never + + # ...and this is just annoying. Thanks, puppet/application.rb. + $stderr.expects(:puts). + with "Could not parse options: I don't know how to render 'interpretive-dance'" + + expect { app.run }.to exit_with 1 + end end end |
