From 6e4f595b391b509a964051f6bb5b55246b0808d6 Mon Sep 17 00:00:00 2001 From: Juan Vasquez Date: Mon, 13 Mar 2023 16:22:25 -0600 Subject: [PATCH] Add sharing? tests --- test/lib/skunk/cli/commands/compare_test.rb | 1 + test/lib/skunk/cli/commands/default_test.rb | 23 +++++++++++++++++++++ test/lib/skunk/cli/commands/help_test.rb | 13 ++++++++---- test/lib/skunk/cli/commands/version_test.rb | 13 ++++++++---- 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 test/lib/skunk/cli/commands/default_test.rb diff --git a/test/lib/skunk/cli/commands/compare_test.rb b/test/lib/skunk/cli/commands/compare_test.rb index 511aaba..cc820f5 100644 --- a/test/lib/skunk/cli/commands/compare_test.rb +++ b/test/lib/skunk/cli/commands/compare_test.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "test_helper" +require "minitest/stub_const" require "skunk/rubycritic/analysed_module" require "skunk/cli/commands/compare" diff --git a/test/lib/skunk/cli/commands/default_test.rb b/test/lib/skunk/cli/commands/default_test.rb new file mode 100644 index 0000000..14da362 --- /dev/null +++ b/test/lib/skunk/cli/commands/default_test.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "test_helper" +require "minitest/stub_const" + +require "skunk/cli/commands/default" + +describe Skunk::Cli::Command::Default do + describe "#sharing?" do + let(:subject) { Skunk::Cli::Command::Default.new({}) } + + it "returns true" do + env = ENV.to_hash.merge("SHARE" => "true") + Object.stub_const(:ENV, env) do + _(subject.sharing?).must_equal true + end + end + + it "returns false" do + _(subject.sharing?).must_equal false + end + end +end diff --git a/test/lib/skunk/cli/commands/help_test.rb b/test/lib/skunk/cli/commands/help_test.rb index ca961ad..0a3505d 100644 --- a/test/lib/skunk/cli/commands/help_test.rb +++ b/test/lib/skunk/cli/commands/help_test.rb @@ -16,15 +16,20 @@ -h, --help Show this message HELP end + let(:options) { ["--help"] } + let(:opts) { Skunk::Cli::Options.new(options).parse } + let(:subject) { Skunk::Cli::Command::Help.new(opts.to_h) } it "outputs the right help message" do - options = ["--help"] - opts = Skunk::Cli::Options.new(options).parse - subject = Skunk::Cli::Command::Help.new(opts.to_h) - assert_output(msg) do subject.execute end end + + describe "#sharing?" do + it "returns false" do + _(subject.sharing?).must_equal false + end + end end end diff --git a/test/lib/skunk/cli/commands/version_test.rb b/test/lib/skunk/cli/commands/version_test.rb index ded860a..b75fc50 100644 --- a/test/lib/skunk/cli/commands/version_test.rb +++ b/test/lib/skunk/cli/commands/version_test.rb @@ -8,15 +8,20 @@ describe Skunk::Cli::Command::Version do describe "#execute" do let(:msg) { Skunk::VERSION } + let(:options) { ["--version"] } + let(:opts) { Skunk::Cli::Options.new(options).parse } + let(:subject) { Skunk::Cli::Command::Version.new(opts.to_h) } it "outputs the right version message" do - options = ["--version"] - opts = Skunk::Cli::Options.new(options).parse - subject = Skunk::Cli::Command::Version.new(opts.to_h) - assert_output(msg) do subject.execute end end + + describe "#sharing?" do + it "returns false" do + _(subject.sharing?).must_equal false + end + end end end