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.
211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/azebiki/azebiki.rb', line 211 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)
258 259 260 |
# File 'lib/azebiki/azebiki.rb', line 258 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.
209 210 211 |
# File 'lib/azebiki/azebiki.rb', line 209 def content @content end |
#errors ⇒ Object
Returns the value of attribute errors.
209 210 211 |
# File 'lib/azebiki/azebiki.rb', line 209 def errors @errors end |
#have_matchers ⇒ Object
Returns the value of attribute have_matchers.
209 210 211 |
# File 'lib/azebiki/azebiki.rb', line 209 def have_matchers @have_matchers end |
#parent_checker ⇒ Object
Returns the value of attribute parent_checker.
209 210 211 |
# File 'lib/azebiki/azebiki.rb', line 209 def parent_checker @parent_checker end |
Instance Method Details
#contains(matching_text) ⇒ Object
223 224 225 226 227 |
# File 'lib/azebiki/azebiki.rb', line 223 def contains(matching_text) selector = MatcherProxy.new(Webrat::Matchers::HasContent.new(matching_text)) @have_matchers << selector selector end |
#matches(name, attributes = {}, &block) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/azebiki/azebiki.rb', line 230 def matches(name, attributes = {}, &block) if block_given? 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
246 247 248 |
# File 'lib/azebiki/azebiki.rb', line 246 def success? @success end |