Sha256: 9bc195dbd8f78e250e303cd4999fdc01dc6a7a80da50251d48850beccfabf2b4

Contents?: true

Size: 727 Bytes

Versions: 2

Compression:

Stored size: 727 Bytes

Contents

module RSpec
  module RubyContentMatchers
    class InheritFrom

      attr_reader :klass

      def initialize(content)
        @klass = klass
      end

      def matches?(content)      
        @content = content
        @content =~ /class\s+(.*?)<\s+#{klass}(.*)end/
        if block_given?
          ruby_content = $2.strip.extend(RSpec::RubyContent::Helpers)
          yield ruby_content
        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  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec_for_generators-0.2.1 lib/rspec_for_generators/matchers/content/inherit_from.rb
rspec_for_generators-0.2.0 lib/rspec_for_generators/matchers/content/inherit_from.rb