lib/boty/rspec.rb in boty-0.1.0 vs lib/boty/rspec.rb in boty-0.1.1

- old
+ new

@@ -6,27 +6,26 @@ def self.included(base) base.instance_eval do include SlackSupport::Users before do - @_bot = Boty::Bot.new( - {"id" => "1234", "name" => "bot"} - ) + @_bot = Boty::Bot.new("id" => "1234", "name" => "bot") + mock_post_message + end - class << Boty::Slack.chat - attr_accessor :messages + let(:bot) { Boty::DSL.new @_bot } + end + end - def post_message(message, options) - @messages ||= [] - @messages << { message: message, options: options } - end - end - end + def mock_post_message + class << Boty::Slack.chat + attr_accessor :messages - let(:bot) { - Boty::DSL.new @_bot - } + def post_message(message, options) + @messages ||= [] + @messages << { message: message, options: options } + end end end def event(options) @_bot.event({ "type" => "message" }.merge options) @@ -37,10 +36,10 @@ end end ::RSpec::Matchers.define :have_responded do |expected| # TODO: add proper messages for failures. - match do |dsl| + match do last_message = Slack.chat.messages.last expected == last_message[:message] end end end