Sha256: 362d65c4b4c91d1609709008da38e2e3748dd7bcab6fdc9066dbc80bd1eaef2f
Contents?: true
Size: 882 Bytes
Versions: 2
Compression:
Stored size: 882 Bytes
Contents
module RSpec::RubyContentMatchers class InheritFrom < RSpec::RubyContentMatcher attr_reader :klass def initialize klass @klass = klass.to_s.camelize end def matches?(content) super 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 super "Expected the class to inherit from #{klass}" end def negative_failure_message super "Did not expect the class to inherit from #{klass}" 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
generator-spec-0.4.5 | lib/generator_spec/matchers/content/inherit_from.rb |
generator-spec-0.4.4 | lib/generator_spec/matchers/content/inherit_from.rb |