module RSpec::RubyContentMatchers class InheritFrom attr_reader :klass def initialize klass @klass = klass.to_s.camelize end def matches?(content) match_res =~ /class\s+(.*?)<\s+#{klass}(.*)end/ if block_given? && match_res ruby_content = $2.strip.extend(RSpec::RubyContent::Helpers) yield ruby_content else match_res end end def failure_message "Expected the class to inherit from #{klass}" end def negative_failure_message "Did not expect the class to inherit from #{klass}" end end def inherit_from(klass) InheritFrom.new(klass) end end