Skip to content

Commit 6e4f595

Browse files
committed
Add sharing? tests
1 parent 0eaba8d commit 6e4f595

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

test/lib/skunk/cli/commands/compare_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require "test_helper"
4+
require "minitest/stub_const"
45

56
require "skunk/rubycritic/analysed_module"
67
require "skunk/cli/commands/compare"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
require "test_helper"
4+
require "minitest/stub_const"
5+
6+
require "skunk/cli/commands/default"
7+
8+
describe Skunk::Cli::Command::Default do
9+
describe "#sharing?" do
10+
let(:subject) { Skunk::Cli::Command::Default.new({}) }
11+
12+
it "returns true" do
13+
env = ENV.to_hash.merge("SHARE" => "true")
14+
Object.stub_const(:ENV, env) do
15+
_(subject.sharing?).must_equal true
16+
end
17+
end
18+
19+
it "returns false" do
20+
_(subject.sharing?).must_equal false
21+
end
22+
end
23+
end

test/lib/skunk/cli/commands/help_test.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@
1616
-h, --help Show this message
1717
HELP
1818
end
19+
let(:options) { ["--help"] }
20+
let(:opts) { Skunk::Cli::Options.new(options).parse }
21+
let(:subject) { Skunk::Cli::Command::Help.new(opts.to_h) }
1922

2023
it "outputs the right help message" do
21-
options = ["--help"]
22-
opts = Skunk::Cli::Options.new(options).parse
23-
subject = Skunk::Cli::Command::Help.new(opts.to_h)
24-
2524
assert_output(msg) do
2625
subject.execute
2726
end
2827
end
28+
29+
describe "#sharing?" do
30+
it "returns false" do
31+
_(subject.sharing?).must_equal false
32+
end
33+
end
2934
end
3035
end

test/lib/skunk/cli/commands/version_test.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88
describe Skunk::Cli::Command::Version do
99
describe "#execute" do
1010
let(:msg) { Skunk::VERSION }
11+
let(:options) { ["--version"] }
12+
let(:opts) { Skunk::Cli::Options.new(options).parse }
13+
let(:subject) { Skunk::Cli::Command::Version.new(opts.to_h) }
1114

1215
it "outputs the right version message" do
13-
options = ["--version"]
14-
opts = Skunk::Cli::Options.new(options).parse
15-
subject = Skunk::Cli::Command::Version.new(opts.to_h)
16-
1716
assert_output(msg) do
1817
subject.execute
1918
end
2019
end
20+
21+
describe "#sharing?" do
22+
it "returns false" do
23+
_(subject.sharing?).must_equal false
24+
end
25+
end
2126
end
2227
end

0 commit comments

Comments
 (0)