Sha256: 15c62a02619ed2ae799ea75290a9b58d11aafa7b3079d8a7d64375525534ce38

Contents?: true

Size: 838 Bytes

Versions: 5

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

describe SlackRubyBot::Commands do
  let! :command do
    Class.new(SlackRubyBot::Commands::Base) do
      command 'set' do |client, data, match|
        if match['expression']
          k, v = match['expression'].split(/\W+/, 2)
          client.say(channel: data.channel, text: "#{match[:command]}: #{k}=#{v}")
        else
          client.say(channel: data.channel, text: (match[:command]).to_s)
        end
      end
    end
  end
  def app
    SlackRubyBot::App.new
  end
  it 'parses expression' do
    expect(message: "#{SlackRubyBot.config.user} set").to respond_with_slack_message('set')
    expect(message: "#{SlackRubyBot.config.user} set x").to respond_with_slack_message('set: x=')
    expect(message: "#{SlackRubyBot.config.user} set x y").to respond_with_slack_message('set: x=y')
  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_with_expression_spec.rb
slack-ruby-bot-0.16.0 spec/slack-ruby-bot/commands/commands_with_expression_spec.rb
slack-ruby-bot-0.15.0 spec/slack-ruby-bot/commands/commands_with_expression_spec.rb
slack-ruby-bot-0.14.0 spec/slack-ruby-bot/commands/commands_with_expression_spec.rb
slack-ruby-bot-0.13.0 spec/slack-ruby-bot/commands/commands_with_expression_spec.rb