Class: Azebiki::Checker
- Inherits:
-
Object
- Object
- Azebiki::Checker
- Defined in:
- lib/azebiki/azebiki.rb
Defined Under Namespace
Classes: MatcherBuilder, MatcherProxy, MyHaveSelector
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#have_matchers ⇒ Object
Returns the value of attribute have_matchers.
-
#parent_checker ⇒ Object
Returns the value of attribute parent_checker.
Instance Method Summary collapse
- #contains(matching_text) ⇒ Object
-
#initialize(content, parent_checker = nil, &block) ⇒ Checker
constructor
A new instance of Checker.
- #matches(name, attributes = {}, &block) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(content, parent_checker = nil, &block) ⇒ Checker
Returns a new instance of Checker.
251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/azebiki/azebiki.rb', line 251 def initialize(content, parent_checker=nil, &block) @content = content @errors = [] @have_matchers = [] @self_before_instance_eval = eval "self", block.binding @matcher_builder = MatcherBuilder.new(&block) @parent_checker = parent_checker build_contents build_matchers run_matchers end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
298 299 300 |
# File 'lib/azebiki/azebiki.rb', line 298 def method_missing(method, *args, &block) @self_before_instance_eval.send method, *args, &block end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
249 250 251 |
# File 'lib/azebiki/azebiki.rb', line 249 def content @content end |
#errors ⇒ Object
Returns the value of attribute errors.
249 250 251 |
# File 'lib/azebiki/azebiki.rb', line 249 def errors @errors end |
#have_matchers ⇒ Object
Returns the value of attribute have_matchers.
249 250 251 |
# File 'lib/azebiki/azebiki.rb', line 249 def have_matchers @have_matchers end |
#parent_checker ⇒ Object
Returns the value of attribute parent_checker.
249 250 251 |
# File 'lib/azebiki/azebiki.rb', line 249 def parent_checker @parent_checker end |
Instance Method Details
#contains(matching_text) ⇒ Object
263 264 265 266 267 |
# File 'lib/azebiki/azebiki.rb', line 263 def contains(matching_text) selector = MatcherProxy.new(Webrat::Matchers::HasContent.new(matching_text)) @have_matchers << selector selector end |
#matches(name, attributes = {}, &block) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/azebiki/azebiki.rb', line 270 def matches(name, attributes = {}, &block) if block_given? parent_checker = @parent_checker || self have = MyHaveSelector.new(name, attributes) do |n| Azebiki::Checker.new(n, parent_checker, &block).success? end selector = MatcherProxy.new(have) else selector = MatcherProxy.new(MyHaveSelector.new(name, attributes)) end @have_matchers << selector selector end |
#success? ⇒ Boolean
286 287 288 |
# File 'lib/azebiki/azebiki.rb', line 286 def success? @success end |