Class: RSpec::RubyContentMatchers::HaveRegion
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RubyContentMatchers::HaveRegion
- Defined in:
- lib/generator_spec/matchers/content/have_region.rb
Instance Attribute Summary collapse
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Attributes inherited from RSpec::RubyContentMatcher
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(region) ⇒ HaveRegion
constructor
A new instance of HaveRegion.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods inherited from RSpec::RubyContentMatcher
Constructor Details
#initialize(region) ⇒ HaveRegion
Returns a new instance of HaveRegion.
5 6 7 |
# File 'lib/generator_spec/matchers/content/have_region.rb', line 5 def initialize(region) @region = region.to_s end |
Instance Attribute Details
#region ⇒ Object (readonly)
Returns the value of attribute region.
3 4 5 |
# File 'lib/generator_spec/matchers/content/have_region.rb', line 3 def region @region end |
Instance Method Details
#failure_message ⇒ Object
19 20 21 22 |
# File 'lib/generator_spec/matchers/content/have_region.rb', line 19 def super "Expected there to be a #{region} region" end |
#matches?(content) ⇒ Boolean
9 10 11 12 13 14 15 16 17 |
# File 'lib/generator_spec/matchers/content/have_region.rb', line 9 def matches?(content) super match_res = (content =~ /#{region}(.*)#{end_epxr}/m) if block_given? && $1 ruby_content = $1.strip.extend(RSpec::RubyContent::Helpers) yield ruby_content end match_res end |
#negative_failure_message ⇒ Object
24 25 26 27 |
# File 'lib/generator_spec/matchers/content/have_region.rb', line 24 def super "Did no expected there to be a #{region} region" end |