Class: RSpec::RubyContentMatchers::HaveClass
- Inherits:
-
Object
- Object
- RSpec::RubyContentMatchers::HaveClass
- Defined in:
- lib/rspec_for_generators/matchers/content/have_class.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(klass) ⇒ HaveClass
constructor
A new instance of HaveClass.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(klass) ⇒ HaveClass
Returns a new instance of HaveClass.
7 8 9 |
# File 'lib/rspec_for_generators/matchers/content/have_class.rb', line 7 def initialize(klass) @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/have_class.rb', line 5 def klass @klass end |
Instance Method Details
#failure_message ⇒ Object
22 23 24 |
# File 'lib/rspec_for_generators/matchers/content/have_class.rb', line 22 def "Expected there to be the class #{klass}" end |
#matches?(content) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rspec_for_generators/matchers/content/have_class.rb', line 11 def matches?(content) @content = content match_res = (@content =~ /class\s+#{@klass}\s+(.*)end/m) if block_given? && $1 ruby_content = $1.strip.extend(RSpec::RubyContent::Helpers) yield ruby_content else match_res end end |
#negative_failure_message ⇒ Object
26 27 28 |
# File 'lib/rspec_for_generators/matchers/content/have_class.rb', line 26 def "Did no expected there to be the class #{klass}" end |