module RSpec::RubyContentMatchers class HaveCalls < HaveCall attr_reader :calls, :method, :args def initialize(*calls) case calls.first when Array, Hash @calls = calls.first else @calls = calls end end def matches?(content) super case calls when Array do_list when Hash do_hash end end protected def do_list calls.each do |method| @method = method.to_s expr = /#{not_def}#{method}/m return false if (content =~ expr) == nil end true end def do_hash calls.each_pair do |method, args| @method = method.to_s @args = args return false if (content =~ /#{not_def}#{method}\s+#{args_expr}/m) == nil end true end end def have_calls(*calls) HaveCalls.new(*calls) end end