Skip to content

Commit

Permalink
Merge pull request #110 from fastruby/add-sharing-test
Browse files Browse the repository at this point in the history
Add sharing? tests
  • Loading branch information
etagwerker authored Apr 30, 2023
2 parents 0eaba8d + 6e4f595 commit e6ea5cf
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
1 change: 1 addition & 0 deletions test/lib/skunk/cli/commands/compare_test.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
23 changes: 23 additions & 0 deletions test/lib/skunk/cli/commands/default_test.rb
Original file line number Diff line number Diff line change
@@ -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
13 changes: 9 additions & 4 deletions test/lib/skunk/cli/commands/help_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 9 additions & 4 deletions test/lib/skunk/cli/commands/version_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e6ea5cf

Please sign in to comment.