Sha256: 31750e061e4014dd744486fe85e61f77210e5cf2033cb70bd6ece92f55d0d476

Contents?: true

Size: 916 Bytes

Versions: 6

Compression:

Stored size: 916 Bytes

Contents

describe SlackRubyBot::Commands, 'permitted?' do
  let! :command do
    Class.new(SlackRubyBot::Commands::Base) do
      class << self
        attr_accessor :_flag1
        attr_accessor :_flag2
        def permitted?(_client, _data, match)
          match[:command] == 'saylo'
        end
      end
      @_flag1 = false
      @_flag2 = false
      command 'saylo' do |_client, _data, _match|
        self._flag1 = true
      end
      command 'sayallowed' do |_client, _data, _match|
        self._flag2 = true
      end
    end
  end
  def app
    SlackRubyBot::App.new
  end

  it 'allows command when returning true' do
    expect(message: "#{SlackRubyBot::Config.user} saylo").to not_respond
    expect(command._flag1).to be true
  end

  it 'denies command when returning false' do
    expect(message: "#{SlackRubyBot::Config.user} sayallowed").to not_respond
    expect(command._flag2).to be false
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
slack-ruby-bot-0.12.0 spec/slack-ruby-bot/commands/commands_permitted_spec.rb
slack-ruby-bot-0.11.2 spec/slack-ruby-bot/commands/commands_permitted_spec.rb
slack-ruby-bot-0.11.1 spec/slack-ruby-bot/commands/commands_permitted_spec.rb
slack-ruby-bot-0.11.0 spec/slack-ruby-bot/commands/commands_permitted_spec.rb
slack-ruby-bot-0.10.5 spec/slack-ruby-bot/commands/commands_permitted_spec.rb
slack-ruby-bot-0.10.4 spec/slack-ruby-bot/commands/commands_permitted_spec.rb