require "spec_helper" require "boty/cli" module Boty RSpec.describe CLI, :thor do subject(:cli) { described_class.new } before(:all) do FileUtils.mkdir_p "tmp" unless Dir.exist? "tmp" FileUtils.chdir "tmp" end before do FileUtils.rm_rf "nice_bot" if Dir.exist? "nice_bot" allow(cli).to receive(:ask) .and_return ENV["SLACK_COMPANY"], ENV["SLACK_BOT_API_TOKEN"] allow(cli).to receive(:run) end after(:all) do FileUtils.rm_rf "nice_bot" if Dir.exist? "nice_bot" FileUtils.chdir "../" end describe "#new PROJECT" do def create_nice_bot capture(:stdout) do cli.new "nice_bot" end end it "creates a directory named after the PROJECT" do expect { create_nice_bot }.to create_directory "nice_bot" end it "creates the executable" do expect { create_nice_bot }.to create_file "nice_bot/bot" end it "creates the empty dir for scripts" do expect { create_nice_bot }.to create_directory "nice_bot/script" end it "creates the empty dir for locales" do expect { create_nice_bot }.to create_directory "nice_bot/locale" end it "creates the empty dir for bot development" do expect { create_nice_bot }.to create_directory "nice_bot/app" end it "creates the Gemfile" do expect { create_nice_bot }.to create_file "nice_bot/Gemfile" end it "creates the Procfile" do expect { create_nice_bot }.to create_file "nice_bot/Procfile" end it "creates the README.md" do expect { create_nice_bot }.to create_file "nice_bot/README.md" end context "/spec" do it "creates the spec/ dir" do expect { create_nice_bot }.to create_directory "nice_bot/spec" end it "creates the .rspec file" do expect { create_nice_bot }.to create_file "nice_bot/.rspec" end end it "turns the ./bot an executable file" do expect(cli).to run "chmod +x bot" create_nice_bot end it "runs bundle install after create the project" do expect(cli).to run "bundle install" create_nice_bot end end end end