Class: RSpec::RubyContentMatchers::HaveSubclass

Inherits:
RSpec::RubyContentMatcher show all
Defined in:
lib/code_spec/matchers/have_subclass.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 RSpec::RubyContentMatcher

#content, #content_matches, #end_option

Instance Method Summary collapse

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(klass, superclass, type = nil) ⇒ HaveSubclass

Returns a new instance of HaveSubclass.



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

def initialize(klass, superclass, type=nil)
  @klass      = klass.to_s.camelize              
  super @klass
  @superclass = superclass.to_s.camelize
  @type       = type.to_s.camelize if type
  @full_class = "#{@klass}#{@type}"
end

Instance Attribute Details

#full_classObject (readonly)

Returns the value of attribute full_class.



3
4
5
# File 'lib/code_spec/matchers/have_subclass.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/have_subclass.rb', line 3

def klass
  @klass
end

#superclassObject (readonly)

Returns the value of attribute superclass.



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

def superclass
  @superclass
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#failure_messageObject



13
14
15
16
# File 'lib/code_spec/matchers/have_subclass.rb', line 13

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

#negative_failure_messageObject



18
19
20
21
# File 'lib/code_spec/matchers/have_subclass.rb', line 18

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