Class: RSpec::RubyContentMatchers::HaveSubClasses

Inherits:
HaveModules show all
Defined in:
lib/code_spec/matchers/multi/have_subclasses.rb

Constant Summary

Constants inherited from RSpec::RubyContentMatcher

RSpec::RubyContentMatcher::ANY_GROUP, RSpec::RubyContentMatcher::LPAR, RSpec::RubyContentMatcher::OPT_ARGS, RSpec::RubyContentMatcher::OPT_SPACES, RSpec::RubyContentMatcher::Q_ANY_GROUP, RSpec::RubyContentMatcher::RPAR, RSpec::RubyContentMatcher::SPACES

Instance Attribute Summary collapse

Attributes inherited from HaveModules

#name, #names, #postfix, #type

Attributes inherited from RSpec::RubyContentMatcher

#alt_end, #content, #content_matches, #end_option

Instance Method Summary collapse

Methods inherited from HaveModules

#is_match?, #matches?

Methods inherited from RSpec::RubyContentMatcher

#any_args_expr, #args_expr, #args_msg, #comment_end, #debug, #debug?, #debug_content, #display, #display_content, #end_expr, #get_expr, #handle_result, #index, #indexes, #is_match?, #matches?, #opt

Constructor Details

#initialize(*names) ⇒ HaveSubClasses

Returns a new instance of HaveSubClasses.



5
6
7
8
9
10
# File 'lib/code_spec/matchers/multi/have_subclasses.rb', line 5

def initialize *names 
  superclass = last_arg_value({:superclass => ''}, names) 
  @superclass = superclass ? superclass.to_s.camelize : nil
  super *names
  @type = :class
end

Instance Attribute Details

#full_classObject (readonly)

Returns the value of attribute full_class.



3
4
5
# File 'lib/code_spec/matchers/multi/have_subclasses.rb', line 3

def full_class
  @full_class
end

#klassObject (readonly)

Returns the value of attribute klass.



3
4
5
# File 'lib/code_spec/matchers/multi/have_subclasses.rb', line 3

def klass
  @klass
end

#superclassObject (readonly)

Returns the value of attribute superclass.



3
4
5
# File 'lib/code_spec/matchers/multi/have_subclasses.rb', line 3

def superclass
  @superclass
end

Instance Method Details

#failure_messageObject



20
21
22
23
# File 'lib/code_spec/matchers/multi/have_subclasses.rb', line 20

def failure_message  
  super
  "Expected there to be the subclass #{full_class} of #{superclass}"
end

#main_exprObject



12
13
14
15
16
17
18
# File 'lib/code_spec/matchers/multi/have_subclasses.rb', line 12

def main_expr      
  if superclass
    'class' + SPACES + "#{full_class}" + OPT_SPACES + '<' + OPT_SPACES + "#{superclass}" + ANY_GROUP
  else
    super
  end
end

#negative_failure_messageObject



25
26
27
28
# File 'lib/code_spec/matchers/multi/have_subclasses.rb', line 25

def negative_failure_message
  super
  "Did no expected there to be the subclass #{full_class} of #{superclass}"
end