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.
227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/azebiki/azebiki.rb', line 227 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)
274 275 276 |
# File 'lib/azebiki/azebiki.rb', line 274 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.
225 226 227 |
# File 'lib/azebiki/azebiki.rb', line 225 def content @content end |
#errors ⇒ Object
Returns the value of attribute errors.
225 226 227 |
# File 'lib/azebiki/azebiki.rb', line 225 def errors @errors end |
#have_matchers ⇒ Object
Returns the value of attribute have_matchers.
225 226 227 |
# File 'lib/azebiki/azebiki.rb', line 225 def have_matchers @have_matchers end |
#parent_checker ⇒ Object
Returns the value of attribute parent_checker.
225 226 227 |
# File 'lib/azebiki/azebiki.rb', line 225 def parent_checker @parent_checker end |
Instance Method Details
#contains(matching_text) ⇒ Object
239 240 241 242 243 |
# File 'lib/azebiki/azebiki.rb', line 239 def contains(matching_text) selector = MatcherProxy.new(Webrat::Matchers::HasContent.new(matching_text)) @have_matchers << selector selector end |
#matches(name, attributes = {}, &block) ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/azebiki/azebiki.rb', line 246 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
262 263 264 |
# File 'lib/azebiki/azebiki.rb', line 262 def success? @success end |