Skip to content

Commit

Permalink
Silence warnings when testing deprecated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsdeleo committed Apr 24, 2014
1 parent d379d9b commit 6d95ac3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions spec/unit/node/attribute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,15 @@
end

describe "index" do
# Hash#index is deprecated and triggers warnings.
def silence
old_verbose = $VERBOSE
$VERBOSE = nil
yield
ensure
$VERBOSE = old_verbose
end

before do
@attributes = Chef::Node::Attribute.new(
{
Expand All @@ -914,13 +923,17 @@

describe "when the value is indexed" do
it "should return the index" do
@attributes.index("six").should == "one"
silence do
@attributes.index("six").should == "one"
end
end
end

describe "when the value is not indexed" do
it "should return nil" do
@attributes.index("lolol").should == nil
silence do
@attributes.index("lolol").should == nil
end
end
end

Expand Down

0 comments on commit 6d95ac3

Please sign in to comment.