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