Sha256: 4f2f0236855deaaaf7e3d004aa3b5eccf9483e481dd0ca03f4c85b12de8e55ad

Contents?: true

Size: 773 Bytes

Versions: 3

Compression:

Stored size: 773 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}"
    end 
    
    def negative_failure_message
      super
      "Did not expect the class to inherit from #{klass}"
    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
  
  def be_active_record    
    InheritFrom.new('ActiveRecord::Base')    
  end
  
end  

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
generator-spec-0.5.0 lib/generator_spec/matchers/content/inherit_from.rb
generator-spec-0.4.8 lib/generator_spec/matchers/content/inherit_from.rb
generator-spec-0.4.7 lib/generator_spec/matchers/content/inherit_from.rb