module Boty RSpec.describe Action, :users do let(:bot) { Bot.new("id" => "U1234", "name" => "boty") } let(:event_data) { { "type" => "message", "text" => "omg lol bbq" } } subject(:action) { Action.new(bot, /omg/, nil) do nil end } it "evals the block in the context of the bot" do dsl = nil bot.match(/omg/) do dsl = self end bot.event event_data expect(dsl.bot).to eq bot end end end