Sha256: 6be9b756efb38f8c84e7573af9c281aac6c28f092c1e8b1f8c4f59ee9577b079

Contents?: true

Size: 1.12 KB

Versions: 17

Compression:

Stored size: 1.12 KB

Contents

require "spec_helper"

describe Lita::Handlers::Help, lita_handler: true do
  it { routes_command("help").to(:help) }
  it { routes_command("help foo").to(:help) }

  describe "#help" do
    let(:secret_handler_class) do
      Class.new(Lita::Handler) do
        route(/secret/, :secret, restrict_to: :the_nobodies, help: {
          "secret" => "no one should ever see this help message"
        })
      end
    end
    it "sends help information for all commands" do
      send_command("help")
      expect(replies.last).to match(
        /#{robot.mention_name}: help.+#{robot.mention_name}: help COMMAND/m
      )
    end

    it "sends help information for commands starting with COMMAND" do
      send_command("help help COMMAND")
      expect(replies.last).to match(/help COMMAND - Lists/)
      expect(replies.last).not_to match(/help - Lists/)
    end

    it "doesn't show help for commands the user doesn't have access to" do
      allow(Lita).to receive(:handlers).and_return([
        described_class,
        secret_handler_class
      ])
      send_command("help")
      expect(replies.last).not_to include("secret")
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
lita-3.3.1 spec/lita/handlers/help_spec.rb
lita-3.3.0 spec/lita/handlers/help_spec.rb
lita-3.2.0 spec/lita/handlers/help_spec.rb
lita-3.1.0 spec/lita/handlers/help_spec.rb
lita-3.0.4 spec/lita/handlers/help_spec.rb
lita-3.0.3 spec/lita/handlers/help_spec.rb
lita-3.0.2 spec/lita/handlers/help_spec.rb
lita-3.0.1 spec/lita/handlers/help_spec.rb
lita-3.0.0 spec/lita/handlers/help_spec.rb
lita-2.7.2 spec/lita/handlers/help_spec.rb
lita-2.7.1 spec/lita/handlers/help_spec.rb
lita-2.7.0 spec/lita/handlers/help_spec.rb
lita-2.6.0 spec/lita/handlers/help_spec.rb
lita-2.5.0 spec/lita/handlers/help_spec.rb
lita-2.4.0 spec/lita/handlers/help_spec.rb
lita-2.3.0 spec/lita/handlers/help_spec.rb
lita-2.2.1 spec/lita/handlers/help_spec.rb