lib/boty/rspec.rb in boty-0.0.4 vs lib/boty/rspec.rb in boty-0.0.6
- old
+ new
@@ -2,14 +2,12 @@
module RSpec
module Bot
def self.included(base)
base.instance_eval do
let(:bot) {
- bot = Boty::Bot.new(
- {"id" => "1234", "name" => "bot"},
- Boty::Session.new(ENV["SLACK_COMPANY"] || "acme")
- )
+ bot = Boty::Bot.new({"id" => "1234", "name" => "bot"},
+ Boty::Session.new)
class << bot
attr_accessor :_response
def say(message)
@@ -20,15 +18,20 @@
bot
}
end
end
+ def event(options)
+ bot.event({ "type" => "message" }.merge options)
+ end
+
def message_event(text)
- bot.event "type" => "message", "text" => text
+ event "text" => text
end
end
::RSpec::Matchers.define :have_responded do |expected|
+ # TODO: add proper messages for failures.
match do |bot|
response = bot._response
bot._response = nil
response == expected
end