Sha256: 33f77891ab95392e38f730f5c27c09302acdf8ae54fe0937d5f6716d9aac24dd

Contents?: true

Size: 741 Bytes

Versions: 2

Compression:

Stored size: 741 Bytes

Contents

module RSpec
  module RubyContentMatchers
    class InheritFrom

      attr_reader :klass

      def initialize(content)
        @klass = klass.to_s.camelize
      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.3.1 lib/rspec_for_generators/matchers/content/inherit_from.rb
rspec_for_generators-0.3.0 lib/rspec_for_generators/matchers/content/inherit_from.rb