Sha256: 393efa651cf6fbb7d1531a035bddbd567ace99984bf4b71d38daca8fc65d1f76

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

module RSpec::RubyContentMatchers
  class InheritFrom < RSpec::RubyContentMatcher
    attr_reader :klass

    def initialize klass
      @klass = klass.to_s.camelize
      super @klass
    end

    def index
      1
    end
  
    def failure_message
      super
      "Expected the class to inherit from #{klass}\ncontent:#{content}"
    end 
    
    def negative_failure_message
      super
      "Did not expect the class to inherit from #{klass}\ncontent:#{content}"
    end
    
    protected

    def main_expr
      'class' + SPACES + Q_ANY_GROUP + '<' + OPT_SPACES + "#{klass}" + ANY_GROUP
    end
  end
  
  def inherit_from(klass)
    InheritFrom.new(klass)
  end 
  alias_method :be_subclass_of, :inherit_from    
end  

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
code-spec-0.4.0 lib/code_spec/matchers/inherit_from.rb
code-spec-0.3.0 lib/code_spec/matchers/inherit_from.rb
code-spec-0.2.11 lib/code_spec/matchers/inherit_from.rb
code-spec-0.2.9 lib/code_spec/matchers/inherit_from.rb