Class: RSpec::RubyContentMatchers::InheritFrom
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RubyContentMatchers::InheritFrom
- Defined in:
- lib/generator_spec/matchers/content/inherit_from.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Attributes inherited from RSpec::RubyContentMatcher
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(klass) ⇒ InheritFrom
constructor
A new instance of InheritFrom.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods inherited from RSpec::RubyContentMatcher
Constructor Details
#initialize(klass) ⇒ InheritFrom
Returns a new instance of InheritFrom.
5 6 7 |
# File 'lib/generator_spec/matchers/content/inherit_from.rb', line 5 def initialize klass @klass = klass.to_s.camelize end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/generator_spec/matchers/content/inherit_from.rb', line 3 def klass @klass end |
Instance Method Details
#failure_message ⇒ Object
20 21 22 23 |
# File 'lib/generator_spec/matchers/content/inherit_from.rb', line 20 def super "Expected the class to inherit from #{klass}" end |
#matches?(content) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/generator_spec/matchers/content/inherit_from.rb', line 9 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 |
#negative_failure_message ⇒ Object
25 26 27 28 |
# File 'lib/generator_spec/matchers/content/inherit_from.rb', line 25 def super "Did not expect the class to inherit from #{klass}" end |