Sha256: edf401f373d564bfcf8bf70589ba9fb32e1c25b0440fdff5aecd8babe24e8e01

Contents?: true

Size: 947 Bytes

Versions: 5

Compression:

Stored size: 947 Bytes

Contents

# frozen_string_literal: true

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

5 entries across 5 versions & 1 rubygems

Version Path
slack-ruby-bot-0.16.1 spec/slack-ruby-bot/commands/commands_permitted_spec.rb
slack-ruby-bot-0.16.0 spec/slack-ruby-bot/commands/commands_permitted_spec.rb
slack-ruby-bot-0.15.0 spec/slack-ruby-bot/commands/commands_permitted_spec.rb
slack-ruby-bot-0.14.0 spec/slack-ruby-bot/commands/commands_permitted_spec.rb
slack-ruby-bot-0.13.0 spec/slack-ruby-bot/commands/commands_permitted_spec.rb