diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2017-04-03 17:38:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-03 17:38:48 -0500 |
commit | 8c5dfde3ddf04593bbe43b758a0649f814d9dfb3 (patch) | |
tree | 37052ea1e66a2ac90e7b43faa9953d78efd507a1 /spec | |
parent | 1ffb0a0fa00f1ef359e42886def859df6fd3e48c (diff) | |
parent | e80e68c4bb4c9efa66d9daedc5082036aefeff49 (diff) | |
download | chef-8c5dfde3ddf04593bbe43b758a0649f814d9dfb3.tar.gz |
Merge pull request #5987 from coderanger/error-info
Expand the system info displayed on error to give us some more data to work with when helping users
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/formatters/error_description_spec.rb | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/spec/unit/formatters/error_description_spec.rb b/spec/unit/formatters/error_description_spec.rb index 8b088308fa..cf6372ed49 100644 --- a/spec/unit/formatters/error_description_spec.rb +++ b/spec/unit/formatters/error_description_spec.rb @@ -49,7 +49,21 @@ describe Chef::Formatters::ErrorDescription do describe "#display" do before do - stub_const("RUBY_PLATFORM", "ruby-foo-9000") + stub_const("Chef::VERSION", "1.2.3") + stub_const("RUBY_DESCRIPTION", "ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]") + allow(subject).to receive(:caller) { Kernel.caller + ["/test/bin/chef-client:1:in `<main>'"] } + allow(File).to receive(:realpath).and_call_original + allow(File).to receive(:realpath).with("/test/bin/chef-client").and_return("/test/bin/chef-client") + end + + around do |ex| + old_program_name = $PROGRAM_NAME + begin + $PROGRAM_NAME = "chef-client" + ex.run + ensure + $PROGRAM_NAME = old_program_name + end end context "when no sections have been added" do @@ -60,9 +74,12 @@ describe Chef::Formatters::ErrorDescription do test title ================================================================================ -Platform: ---------- -ruby-foo-9000 +System Info: +------------ +chef_version=1.2.3 +ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] +program_name=chef-client +executable=/test/bin/chef-client END end @@ -84,9 +101,37 @@ test heading ------------ test text -Platform: ---------- -ruby-foo-9000 +System Info: +------------ +chef_version=1.2.3 +ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] +program_name=chef-client +executable=/test/bin/chef-client + + END + end + + end + + context "when node object is available" do + it "should output the expected sections" do + # This can't be in a before block because the spec-wide helper calls a + # reset on global values. + Chef.set_node({ "platform" => "openvms", "platform_version" => "8.4-2L1" }) + subject.display(out) + expect(out.out.string).to eq <<-END +================================================================================ +test title +================================================================================ + +System Info: +------------ +chef_version=1.2.3 +platform=openvms +platform_version=8.4-2L1 +ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] +program_name=chef-client +executable=/test/bin/chef-client END end |