Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/pod/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ def self.exit_on_failure?
true
end

def self.start(given_args = ARGV, config = {})
command = given_args.first
does_not_require_config = %w[version -V --version init].include?(command)
pod_initialized = Dir.exist?(ENV["HOME"] + "/.config/pod")
if does_not_require_config || pod_initialized
super
else
puts "Missing config files. Run `pod init` first."
end
end

desc "version", "Displays the pod version"
map %w[-V --version] => :version
def version
Expand Down
14 changes: 13 additions & 1 deletion spec/pod/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative "../support/test_helpers"

RSpec.describe Pod::CLI do
describe "input interpretation" do
describe "input interpretation", :init_pod do
context "when the input is invalid" do
it "tells the user that the command was not found" do
result = TestHelpers::CLI.run_cmd("pod invalid")
Expand All @@ -13,6 +13,18 @@
end
end

describe "init ensuring" do
it "returns an error message when user tries to run pod without initialization" do
expected_output = <<~OUTPUT
Missing config files. Run `pod init` first.
OUTPUT

result = TestHelpers::CLI.run_cmd("pod podcasts")

expect(result).to eq(expected_output.chomp)
end
end

describe "version command" do
it "returns the pod version" do
original_result = TestHelpers::CLI.run_cmd("pod version")
Expand Down