Sha256: fe17ae29a25b24882345660eb074dba61ff88ffe5a235789970d713f9c517314

Contents?: true

Size: 1.21 KB

Versions: 17

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

RSpec.describe Twitch::Bot::Message::UserMessage do
  it "recognizes a bot command" do
    message = described_class.new(
      text: "!command argument1",
      user: "tester",
    )

    expect(message.command?).to be true
  end

  it "recognizes a specific bot command" do
    message = described_class.new(
      text: "!command argument1",
      user: "tester",
    )

    expect(message.command_name?("command")).to be true
  end

  it "does not recognize normal text as a command" do
    message = described_class.new(
      text: "nocommand here",
      user: "tester",
    )

    expect(message.command?).to be false
  end

  it "does not mistake text for a command" do
    message = described_class.new(
      text: "nocommand here",
      user: "tester",
    )

    expect(message.command_name?("nocommand")).to be false
  end

  it "parses a bot command" do
    message = described_class.new(
      text: "!command argument1",
      user: "tester",
    )

    expect(message.command).to eq "command"
  end

  it "does not return a command for normal text" do
    message = described_class.new(
      text: "nocommand here",
      user: "tester",
    )

    expect(message.command).to be nil
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
twitch-bot-6.0.0 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-5.0.6 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-5.0.5 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-5.0.4 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-5.0.2 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-5.0.1 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-5.0.0 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-4.1.1 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-4.1.0 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-4.0.1 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-4.0.0 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-3.2.1 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-3.2.0 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-3.1.0 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-2.1.1 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-2.1.0 spec/twitch/bot/message/user_message_spec.rb
twitch-bot-2.0.1 spec/twitch/bot/message/user_message_spec.rb