Sha256: d4232da8f686e04783277f6d479f5e4e03090dfc71add6f731427144979efa95
Contents?: true
Size: 1.45 KB
Versions: 5
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true describe SlackRubyBot::Commands::Base do let! :command1 do Class.new(SlackRubyBot::Commands::Base) do command 'command' def self.call(client, data, match) client.say(channel: data.channel, text: "#{match[:command]}: #{match[:expression]}") end end end let! :command2 do Class.new(SlackRubyBot::Commands::Base) do command 'command' def self.call(client, data, match) client.say(channel: data.channel, text: "#{match[:command]}: #{match[:expression]}") end end end def app SlackRubyBot::App.new end describe '#command_classes' do it 'returns all registered command classes' do expect(SlackRubyBot::Commands::Base.command_classes).to include command1 expect(SlackRubyBot::Commands::Base.command_classes).to include command2 end it 'returns command1 before command2' do command_classes = SlackRubyBot::Commands::Base.command_classes expect(command_classes.find_index(command1)).to be < command_classes.find_index(command2) end it 'uses the object_id of an anonymous class as the default command name' do command_classes = SlackRubyBot::Commands::Base.command_classes anon_class = Class.new(SlackRubyBot::Commands::Base) expect(command_classes).to include anon_class expect(command_classes.find { |obj| obj == anon_class }.object_id.to_s).to eq anon_class.command_name_from_class end end end
Version data entries
5 entries across 5 versions & 1 rubygems