Merge pull request #6391 from MikeMcQuaid/messages-frozen

messages_spec: handle frozen Homebrew.args.
This commit is contained in:
Mike McQuaid 2019-08-21 09:28:03 +01:00 committed by GitHub
commit 44f43fd5f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,9 +72,11 @@ describe Messages do
end end
end end
# Homebrew.args OpenStruct usage cannot use verified doubles.
# rubocop:disable RSpec/VerifiedDoubles
context "when the --display-times argument is present" do context "when the --display-times argument is present" do
before do before do
allow(Homebrew.args).to receive(:display_times?).and_return(true) allow(Homebrew).to receive(:args).and_return(double(display_times?: true))
end end
context "when install_times is empty" do context "when install_times is empty" do
@ -101,12 +103,13 @@ describe Messages do
context "when the --display-times argument isn't present" do context "when the --display-times argument isn't present" do
before do before do
allow(ARGV).to receive(:include?).with("--display-times").and_return(false) allow(Homebrew).to receive(:args).and_return(double(display_times?: false))
end end
it "doesn't print installation times" do it "doesn't print installation times" do
expect { messages.display_messages }.not_to output.to_stdout expect { messages.display_messages }.not_to output.to_stdout
end end
end end
# rubocop:enable RSpec/VerifiedDoubles
end end
end end