Sha256: 12d5ee2bb1cb742b82c8e4d06d3385231cedcba2c5d2beb93616e4329b4a186e
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
Contents
require "support/thor_support" require "boty/cli" module TemplateProjectSupport include ThorSupport def dry_run allow(cli).to receive(:run) end def create_bot(name = nil, company:, api_key:) allow(cli).to receive(:ask).and_return company, api_key cli.new name || bot_name end def self.included(base) base.instance_eval do before(:all) do go_to_tmp_project_dir end before do FileUtils.rm_rf bot_name if Dir.exist? bot_name end after(:all) do remove_tmp_project_dir end subject(:cli) { Boty::CLI.new } let(:bot_name) { "jeeba" } end end private def go_to_tmp_project_dir @original_dir = FileUtils.pwd FileUtils.mkdir_p "tpl_project_tmp" unless Dir.exist? "tpl_project_tmp" FileUtils.chdir "tpl_project_tmp" end def remove_tmp_project_dir FileUtils.chdir @original_dir FileUtils.rm_rf "tpl_project_tmp" end end RSpec::Matchers.define :run do |command| match do |bot| expect(bot).to receive(:run).with command end end
Version data entries
5 entries across 5 versions & 1 rubygems