Sha256: 0e1a15c04a9b42546e0f801e7fe8c8ea86b8e2709f727dc5f0b522e95a803628

Contents?: true

Size: 1.48 KB

Versions: 7

Compression:

Stored size: 1.48 KB

Contents

require "spec_helper"

describe Lita::Response do
  subject { described_class.new(message, /dummy regexp/) }

  let(:message) { instance_double("Lita::Message").as_null_object }

  [:args, :reply, :reply_privately, :reply_with_mention, :user, :command?].each do |method|
    it "delegates :#{method} to #message" do
      expect(message).to receive(method)
      subject.public_send(method)
    end
  end

  describe "#matches" do
    it "matches the pattern against the message" do
      expect(message).to receive(:match).with(subject.pattern)
      subject.matches
    end
  end

  describe "#match_data" do
    let(:body) { instance_double("String") }

    it "matches the message body against the pattern" do
      allow(message).to receive(:body).and_return(body)
      expect(subject.pattern).to receive(:match).with(message.body)
      subject.match_data
    end
  end

  describe "#extensions" do
    it "can be populated with arbitrary data" do
      subject.extensions[:foo] = :bar

      expect(subject.extensions[:foo]).to eq(:bar)
    end
  end

  describe "#user" do
    it "delegates to #message" do
      expect(subject.message).to receive(:user)
      subject.user
    end
  end

  describe "#room" do
    it "delegates to #message" do
      expect(subject.message).to receive(:room_object)
      subject.room
    end
  end

  describe "#private_message?" do
    it "delegates to #message" do
      expect(subject.message).to receive(:private_message?)
      subject.private_message?
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lita-4.8.0 spec/lita/response_spec.rb
lita-4.8.0.beta1 spec/lita/response_spec.rb
lita-4.7.1 spec/lita/response_spec.rb
lita-4.7.0 spec/lita/response_spec.rb
lita-4.6.1 spec/lita/response_spec.rb
lita-4.6.0 spec/lita/response_spec.rb
lita-4.5.0 spec/lita/response_spec.rb